angular-ui/ui-grid

Using $viewContentLoaded with ui-grid throws "Cannot read property 'data' of undefined"

Open

#6,250 opened on Jun 5, 2017

View on GitHub
 (0 comments) (2 reactions) (1 assignee)JavaScript (2,496 forks)batch import
good first issue

Repository metrics

Stars
 (5,395 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Using ui-grid with $viewContentLoaded throws the following error, because data and the grid are not initialized until the view is loaded. Ui-grid works fine but spits out this error,

angular.js:14525 TypeError: Cannot read property 'data' of undefined
    at new <anonymous> (ui-grid.js:3332)
    at Object.invoke (angular.js:5003)
    at $controllerInit (angular.js:10866)
    at nodeLinkFn (angular.js:9746)
    at angular.js:10154
    at processQueue (angular.js:16832)
    at angular.js:16876
    at Scope.$digest (angular.js:17971)
    at Scope.$apply (angular.js:18269)
    at bootstrapApply (angular.js:1917)

Line in question:

      } else {
        if (angular.isString($scope.uiGrid.data)) {
          deregFunctions.push( $scope.$parent.$watchCollection($scope.uiGrid.data, dataWatchFunction) );
        } else {
...
      }

Contributor guide