Hi, I have a JSON array that I am calling from a service. I have some counters that I would like to print the length of the full array and the length of some subelements. I can print the entire length of the array, but I would also like to print the total number of elements that have a progress of "green", "red" and "yellow". Seeing that this is an array of objects, how am I going to get the length of green, red, yellow?
JSON:
[
{
name: User1,
progress: "green"
},
{
name: User2,
progress: "yellow"
},
{
name: User3,
progress: "green"
},
{
name: User4,
progress: "red"
},
]
I store a service called like this:
$scope.requestDetails = [];
$scope.requestDetails = data;
HTML:
<div class="total">{{requestDetails.length}}</div>
<div class="red"></div>
<div class="yellow"></div>
<div class="green"></div>
Out of curiosity, I tried to print {{requestDetails.progress.length}}, but it was empty, and printing {{requestDetails[0].progress.length}}prints the number of letters of the first value of the progress of the object.