我想使用解決方案。我需要從加載控制器和視圖之前的服務獲取數據。我發現了一些如何使用解決方案。爲什麼我在使用angular js中的解析時出錯?
我在項目中沒有得到錯誤,當我刪除決心聲明
.state('a', {
url: "/a",
templateUrl: "a.html",
controller: 'a',
// resolve:{
// messsage:function(testservice){
// return testservice.getdata();
// }
//}
})
當我取消的決心聲明我得到這個錯誤
**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**
這裏是我的代碼 http://plnkr.co/edit/fk7IGcYlDfZasWqzy31S?p=preview
我想在使用控制器之前加載服務中的數據,然後加載到查看
你在你的索引頁面腳本調用中使用'angular.min.js'還是完整'angular.js'? –
我創建了類似的例子,它顯示瞭解決方案http://plnkr.co/edit/iY0sCnM5dzvassz2k0KL?p=preview –