我有一個應用程序,其中有一些用於過濾數據的下拉列表。一旦我將json移動到firebase,我無法檢索這些下拉列表中的數據。 app當應用程序遷移到firebase時數據未加載
的FOLL是控制檯錯誤:
TypeError: Cannot read property 'tags' of undefined
at classifieds.ctr.js:135
at Object.forEach (angular.js:321)
at getTags (classifieds.ctr.js:134)
at classifieds.ctr.js:20
at processQueue (angular.js:15552)
at angular.js:15568
at Scope.$eval (angular.js:16820)
at Scope.$digest (angular.js:16636)
at angular.js:16859
at completeOutstandingRequest (angular.js:5804)
的FOLL是代碼:
angular
.module("ngClassifieds")
.controller("classifiedsCtrl", function($scope, $state, $http, classifiedsFactory, $mdSidenav, $mdToast, $mdDialog) {
$scope.classifieds = classifiedsFactory.ref;
$scope.classifieds.$loaded().then(function(classifieds) {
$scope.tags = getTags(classifieds); // call the getTags method below
$scope.books = getBooks(classifieds); // call the getBooks method below
$scope.authors = getAuthors(classifieds); // call the getAuthors method below
$scope.order = ""; //for sorting in asc or desc order
});
的FOLL是getTags方法:
function getTags(classifieds) {
var tags = [];
angular.forEach(classifieds, function(item) {
angular.forEach(item.meta.tags, function(tag) {
tags.push(tag);
});
});
return _.uniq(tags);
}
的FOLL是在Firefox中的錯誤: 無法訪問的代碼後R返回聲明
Error: item.meta is undefined
getTags/<@http://localhost:8080/components/classifieds/classifieds.ctr.js:135:5
[email protected]://localhost:8080/node_modules/angular/angular.js:321:11
[email protected]://localhost:8080/components/classifieds/classifieds.ctr.js:134:4
@http://localhost:8080/components/classifieds/classifieds.ctr.js:20:18
[email protected]://localhost:8080/node_modules/angular/angular.js:15552:28
scheduleProcessQueue/<@http://localhost:8080/node_modules/angular/angular.js:15568:27
$RootScopeProvider/this.$get</[email protected]://localhost:8080/node_modules/angular/angular.js:16820:16
$RootScopeProvider/this.$get</[email protected]://localhost:8080/node_modules/angular/angular.js:16636:15
$RootScopeProvider/this.$get</Scope.prototype.$evalAsync/<@http://localhost:8080/node_modules/angular/angular.js:16859:15
[email protected]://localhost:8080/node_modules/angular/angular.js:5804:7
Browser/self.defer/timeoutId<@http://localhost:8080/node_modules/angular/angular.js:6081:7
編號真的很感激,如果你能幫助我在那裏IM布萊恩錯在這裏。謝謝
請參閱[使用緩存加入用戶記錄](https://gist.github.com/katowulf/f78d4a224c06a643ddfa)和[使用$ extend過濾記錄](https://gist.github.com/katowulf/bee266e31aa60cb0eed6) – Kato