I am new to Angular and I am trying to declare gridOption for ng-grid. In function in costroller.
This causes an error:
TypeError: Unable to set property 'gridDim' from undefined
I tried to solve it using $ scope.apply and ng-if in the template. But none of this works for me.
Thanks for any advice:
controller method:
$scope.getTest = function() { $http.get('http://www.iNorthwind.com/Service1.svc/getAllCustomers') .success(function (data, status, headers, config) { //$scope.myData = data; console.log('Sucess' + data); // definition for ng-grid table $scope.myData = [{ name: "Moroni", age: 50 }, { name: "Tiancum", age: 43 }, { name: "Jacob", age: 27 }, { name: "Nephi", age: 29 }, { name: "Enos", age: 34}]; $scope.gridOptions = { data: 'myData' }; //$scope.$apply(); }) .error(function(data, status, headers, config) { $scope.myData = data; }); };
source share