I need help not sure what I'm missing. I am trying to loop through an array of objects in Angular to find count of a specific field in objects. For instance I want to find out how many ID's came in with the risk of 'Moderate', 'High','Low'?
I can count the total amount of objects for having trouble counting the number of risks associated with a type of risk like 'Moderate'
json:
[
{"id": 1,
"risk": "Moderate"
},
{"id": 2,
"risk": "Low"
},
{"id": 3,
"risk": "Moderate"
},
{"id": 4,
"risk": "High"
}]
component.ts
countTotalChanges() {
let count = 0;
for (var i = 0; i < this.changeService.length; i++) {
count++;
}
return count;
}
HTML
{{countTotalChanges()}}