Accessing thhe the length of items within a ng-repeat seems simple. {{array.length}}
But when you have to iterate trough objects and you have to know the total objects then you don't have a Angular thing for it.
What I did now is count the total properties and store it in a variable.
$scope.totalPersons = Object.keys($scope.data).length;
But when items are added to the object the totalPersons
is not updated so
I changed this so the value will be updated.
$scope.$watch( $scope.data, function (newValue, oldValue) {
$scope.totalPersons = Object.keys($scope.data).length;
});
But is there a better way to access the total objects in your template?
<ul>
<li ng-repeat="(key, value) in data">
{{key}} - {{value}} {{totalPersons}}
</li>
</ul>