I have an application where i have some dropdowns that are used to filter data. Once i moved the json to firebase, i am unable to retrieve data in these dropdowns. app
The foll is the console error:
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)
The foll is the code:
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
});
The foll is the getTags method:
function getTags(classifieds) {
var tags = [];
angular.forEach(classifieds, function(item) {
angular.forEach(item.meta.tags, function(tag) {
tags.push(tag);
});
});
return _.uniq(tags);
}
The foll is the error in firefox: unreachable code after return statement
Error: item.meta is undefined
getTags/<@http://localhost:8080/components/classifieds/classifieds.ctr.js:135:5
forEach@http://localhost:8080/node_modules/angular/angular.js:321:11
getTags@http://localhost:8080/components/classifieds/classifieds.ctr.js:134:4
@http://localhost:8080/components/classifieds/classifieds.ctr.js:20:18
processQueue@http://localhost:8080/node_modules/angular/angular.js:15552:28
scheduleProcessQueue/<@http://localhost:8080/node_modules/angular/angular.js:15568:27
$RootScopeProvider/this.$get</Scope.prototype.$eval@http://localhost:8080/node_modules/angular/angular.js:16820:16
$RootScopeProvider/this.$get</Scope.prototype.$digest@http://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
completeOutstandingRequest@http://localhost:8080/node_modules/angular/angular.js:5804:7
Browser/self.defer/timeoutId<@http://localhost:8080/node_modules/angular/angular.js:6081:7
Id really appreciate if you can help me figure where im goin wrong here. Thanks