[英]FIREBASE WARNING: Exception was thrown by user callback. Error: [$rootScope:inprog] http://errors.angularjs.org/1.4.7/$rootScope/inprog?p0=%24digest
我遇到一個錯誤,是隨機的,有時會發生,有時不會。 我無法確定要解決的問題。
有誰知道錯誤的原因或如何防止?
我的代碼:
angular.module('VigiApp').controller('FeedsController', ['$scope', 'gettextCatalog', 'FirebaseURL', '$ngBootbox', function($scope, gettextCatalog, FirebaseURL, $ngBootbox) {
$scope.contents = [];
isSpinnerBar(false);
$scope.init = function(){
isSpinnerBar(true);
// Get a database reference to our posts
//auth
var fbAuth = FirebaseURL.getAuth();
//Ref
var norm = new Firebase.util.NormalizedCollection(
FirebaseURL.child('contents'),
[FirebaseURL.child('categories'), 'category', 'contents.category_id']
);
// get a reference we can use like a normal Firebase instance
ref = norm.select('contents.category_id',
'contents.dt_created',
'contents.num_comment',
'contents.num_favorite',
'contents.text',
'contents.photos',
'contents.user_id',
{key: 'category.name.$value', alias: 'category_name'},{key: "category."+$scope.currentLanguage+".$value", alias: 'category_name_language'},{key: 'category.icon.$value', alias: 'category_icon'}).ref();
// Attach an asynchronous callback to read the data at our posts reference
ref.orderByChild("dt_created").limitToFirst(2).on("value", function(snapshot) {
console.log(snapshot.val());
var res = snapshot.val();
$scope.$apply(function() {
$scope.contents = res;
isSpinnerBar(false);
isButtonActivedFeed();
});
}, function (errorObject) {
console.log("The read failed: " + errorObject.code);
isSpinnerBar(false);
});
}
$scope.share = function(e){
}
}]);
警告:
FIREBASE WARNING: Exception was thrown by user callback. Error: [$rootScope:inprog] http://errors.angularjs.org/1.4.7/$rootScope/inprog?p0=%24digest
....
好的,為帖子道歉,我在Google上進行了大量搜索后找到了解決方案。
我一直在尋找firebase或firebase-util,但是在頁面之間導航時我的角度是一個錯誤。
該解決方案為我工作:
var res = snapshot.val();
$timeout(function(){
$scope.$apply(function() {
$scope.contents = res;
isSpinnerBar(false);
isButtonActivedFeed();
});
});
解決方案,原因: AngularJS:調用$ scope。$ apply()時,防止錯誤$ digest已經在進行中。
請,如果其他人有相同的問題/疑問,我將繼續提問。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.