Search code examples
angularjsdatatablesangular-directiveangular-datatables

TypeError: _parentScope.$watchCollection is not a function Angular - datatables


Getting this error when trying to load Angular-datatables.

Includes:

<script src="//code.jquery.com/jquery-3.1.1.min.js"></script>
    <script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-datatables/0.5.5/angular-datatables.js"></script>

Error:

angular.min.js:63 TypeError: _parentScope.$watchCollection is not a function
    at Object.render (angular-datatables.js:901)
    at angular-datatables.js:124
    at h (angular.min.js:78)
    at angular.min.js:78
    at Object.$eval (angular.min.js:89)
    at Object.$digest (angular.min.js:86)
    at Object.$apply (angular.min.js:89)
    at angular.min.js:16
    at Object.d [as invoke] (angular.min.js:28)
    at c (angular.min.js:16)(anonymous function) @ angular.min.js:63

Solution

  • angular 1.0.8 does not support in $watchCollection. try to update the angularjs script: here the final stable version of angular:

        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>