Reputation: 1574
I am trying to use resolve .Mean I need to get data from service before loading the controller and view .I found some line how to use resolve .
I an not getting error in my project when I remove resolve statement
.state('a', {
url: "/a",
templateUrl: "a.html",
controller: 'a',
// resolve:{
// messsage:function(testservice){
// return testservice.getdata();
// }
//}
})
when I uncomment the resolve statement I got this error
**Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.3.13/$rootScope/infdig?p0=10&p1=%5B%5D
at REGEX_STRING_REGEXP (ionic.bundle.js:8762)
at Scope.promises.$get.Scope.$digest (ionic.bundle.js:22980)
at Scope.promises.$get.Scope.$apply (ionic.bundle.js:23205)
at done (ionic.bundle.js:18358)
at completeRequest (ionic.bundle.js:18548)
at XMLHttpRequest.requestLoaded (ionic.bundle.js:18489)(anonymous function) @ ionic.bundle.js:20306jqNodes.$get @ ionic.bundle.js:17256promises.$get.Scope.$apply @ ionic.bundle.js:23207done @ ionic.bundle.js:18358completeRequest @ ionic.bundle.js:18548requestLoaded @ ionic.bundle.js:18489
ionic.bundle.js:8762 Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.3.13/$rootScope/infdig?p0=10&p1=%5B%5DREGEX_STRING_REGEXP @ ionic.bundle.js:8762promises.$get.Scope.$digest @ ionic.bundle.js:22980promises.$get.Scope.$apply @ ionic.bundle.js:23205done @ ionic.bundle.js:18358completeRequest @ ionic.bundle.js:18548requestLoaded @ ionic.bundle.js:18489
ionic.bundle.js:20306 Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.3.13/$rootScope/infdig?p0=10&p1=%5B%5D
at REGEX_STRING_REGEXP (ionic.bundle.js:8762)
at Scope.promises.$get.Scope.$digest (ionic.bundle.js:22980)
at Scope.promises.$get.Scope.$apply (ionic.bundle.js:23205)
at done (ionic.bundle.js:18358)
at completeRequest (ionic.bundle.js:18548)
at XMLHttpRequest.requestLoaded**
here is my code http://plnkr.co/edit/fk7IGcYlDfZasWqzy31S?p=preview
I am trying to load data from service before using in controller and before loading to view
Upvotes: 0
Views: 430
Reputation: 423
Use the good syntax for your service
factory('testservice', ['$http',
function testservice($http) {
Fetch the data in your controller :
$scope.data = testservice.getdata();
The plnk : http://plnkr.co/edit/2EskRAzVPo8lhXyaLFuy?p=preview
Then you should consider backing your data in the service so you call $http.get("data.json")
one time.
Upvotes: 1