【发布时间】:2014-07-24 04:40:42
【问题描述】:
我正在将 firebase 与 AngularJS 集成,但在使用 promise 中的 firebase 快照结果时遇到了一些问题。
以下是我在ui-router中的一种状态的代码:
resolve: {
opinionConfig: function($stateParams, $location, $q, ConstantsService) {
var result = $q.defer();
var processResponse = function(value) {
value.opinion = $stateParams.opinion;
result.resolve(value);
};
var rootRef = new Firebase(ConstantsService.FIREBASE_URL + 'configs/' + $stateParams.opinion);
rootRef.once('value', function(snapshot) {
if (snapshot.val() === null) {
$location.path('/');
// console.log("configs doesn't exist.");
result.reject("configs doesn't exist");
} else {
// console.log("configs does exist: " + snapshot.val());
processResponse(angular.copy(snapshot.val()));
}
});
return result.promise;
}
}
我在 Firefox 的开发者工具中遇到了这个错误。
这就是我在 Chrome 的开发者工具中得到的。
这两个错误似乎不同,我找不到 firebase.js 的官方未缩小版本,所以我不确定这是在哪里抛出的。
谢谢,
卢克
【问题讨论】:
标签: javascript angularjs firebase angular-ui-router angularfire