I am currently working on angular app and bumped into a problem. The problem is when I'm getting the data form backend through factory into controller, eventhrough I apply this data to scope I can't access it later in this controller.
My fist try:
Schema.list.get().$promise.then(function (data) {
$scope.schema= data;
});
With this method I can print data in my view but if I when I want to access it in controller scope is undefined.
Second try:
Schema.list.get().$promise.then(function (data) {
$scope.$apply(function() {
$scope.schema= data;
});
});
When I use $scope.$apply I got an error like this:
Error: [$rootScope:inprog] $digest already in progress
http://errors.angularjs.org/1.4.6/$rootScope/inprog?p0=%24digest
at angular.js:68
at beginPhase (angular.js:16279)
at Scope.$apply (angular.js:16020)
at racunanje.client.controller.js:11
at processQueue (angular.js:14678)
at angular.js:14694
at Scope.$eval (angular.js:15922)
at Scope.$digest (angular.js:15733)
at Scope.$apply (angular.js:16030)
at done (angular.js:10545)
Thank you in advance for any help you can give me.