Answer the question
In order to leave comments, you need to log in
Why doesn't Angular count objects?
I am getting objects from a factory, the factory is pulling them from Firebase.
This is what the controller looks like (partially):
$scope.customers = [];
function getTotal() {
$scope.custTotal = $scope.customers.length;
}
function init() {
$scope.customers = customersFactory.getCustomers();
getTotal();
}
init();
[{"city":"Rutten","id":1,"joined":"2011-05-02","name":"Tanner","orders":[{"id":2,"product":"Left shoe","total":2.95}],"$id":"0","$priority":null},{"city":"San Francisco","id":2,"joined":"2011-12-12","name":"Joffrey","orders":[{"id":1,"product":"Right shoe","total":4.95},{"id":2,"product":"Left shoe","total":9.95}],"$id":"1","$priority":null}]
Answer the question
In order to leave comments, you need to log in
It seems to me that you have a very strange decision. I would do
function getTotal() {
return $scope.customers.length;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question