0

I am trying to find the length of an array from firebase using the following code:

(function() {
    'use strict';

    angular
        .module('com.td.oca.tDUITestHomepage')
        .controller('HomepageController', ['$scope', '$firebaseArray', function($scope, $firebaseArray) {
            $scope.greeting = 'Hola!';
            $scope.vm = this;

            $scope.fireData = new Firebase('https://mdm-ui-test-data.firebaseio.com/');

            $scope.vm.addData = addData;
            function Data() {
                name:'';
                address:'';
                postalCode:'';
            }

            $scope.vm.newData = new Data();
            $scope.vm.dataList = $firebaseArray($scope.fireData);
            $scope.testingLength = $scope.vm.dataList.length;
            $scope.testing = $scope.vm.dataList;

        }]);

})();

however, scope.testing returns: [{"name":"person A","phone":"11111111111","postalCode":"L1T3Y2"},{"name":"person B","phone":"222222222222","postalCode":"L24YTW"},{"name":"person C","phone":"33333333333","postalCode":"au43rt"}]

I believe that $scope.testingLength should be returning a length of 3, however, it is returning a length of 0. can anyone explain why this is happening?

Graeham Broda
  • 131
  • 1
  • 6
  • 15

1 Answers1

0

by following the advice on this post: How to loop through $firebaseArray

I was able to solve the problem

Community
  • 1
  • 1
Graeham Broda
  • 131
  • 1
  • 6
  • 15