gpt4 book ai didi

javascript - w/firebase.js 和 Angular UI Router 的问题

转载 作者:行者123 更新时间:2023-12-03 12:11:55 25 4
gpt4 key购买 nike

我正在将 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 的开发者工具中遇到此错误。

enter image description here

这就是我在 Chrome 开发者工具中得到的内容。

enter image description here

这两个错误似乎不同,而且我找不到 firebase.js 的官方未缩小版本,所以我不确定这到底是在哪里抛出的。

谢谢

卢克

最佳答案

您正在使用 js 的最小版本(错误显示angular.min...)

然后是这个

opinionConfig: function($stateParams, $location, $q, ConstantsService) {

转换成这样

opinionConfig: function(c, x, g, r) { // an example showing minification

所以我们要做的是:

opinionConfig: 
['$stateParams', '$location', '$q', 'ConstantsService',
function($stateParams, $location, $q, ConstantsService) {

也许还可以检查一下这个Minified AngularJS gives me unreadable errors

关于javascript - w/firebase.js 和 Angular UI Router 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24925255/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com