Hey I have a JSON array that I'm calling from a service. I have some counters that I'd like to print out the length of the total array and length of some sub items. I'm able to print out the full length of the array but I also would like to print out the total number of items that have a progress "green", "red", and "yellow". Seeing that it's an array of objects, how would I go about 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'm storing the service called as so:
$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 comes up empty and printing {{requestDetails[0].progress.length}}
prints out the number of letters of the first object's progress value.