I am trying to display exactly how many of an array variable I have, not just the items in the array, but one of the 'tags' assigned to it.
$scope.products = [
{
too: 'xxx-xxx-xxx',
foo: 'xxx',
bar: 'xxx-xxx',
}
}
];
When I try to list the length of one of the 'tags' for example "Foo".
Using {{foo.length}} will not work.
I would want my HTML to look something like this:
Menu 1 (1) <--- With this being the "foo" value.
*The foo value will change based on the amount of 'items' i have in my array, so if I had an array like this:
$scope.products = [
{
too: 'xxx-xxx-xxx',
foo: 'xxx',
bar: 'xxx-xxx',
}
{
too: 'yyy-yyy-yyy',
foo: 'yyy',
bar: 'yyy-yyy',
}
}
];
the HTML would reflect that I now have '2' values of 'foo', so it would say Menu 1 (2), and so on and so forth.. How can I accomplish this?
$scope.products.filter(function (item) { return item.hasOwnProperty('foo') }).length-- try this. This will give the number of elements having foo property