0

I am trying to get the array length, when i console log

console.log($scope.community)

I do get a return, but when i try doing the method i found online , like Get the object length in angularjs is undefined

   var array = Object.keys($scope.community);
   var len = array.length;
   console.log(len)

I am returned with 0 and no error

enter image description here

Array call :

    var all = displayAll.callAll()
        .then(function(response) {
           $scope.all = response;
           for (var i=0; i< $scope.all.length; i++) {

                if ($scope.all[i].CATEGORY == 'Community')
                {
                    $scope.community.push($scope.all[i]);

                }
HangulSR
  • 259
  • 2
  • 10

1 Answers1

0
var len = $scope.community.length;
console.log(len);

should return the length of the community. Plus this method can also be used in Native JS, even without using AngularJS.

Kelvin
  • 102
  • 4