in my foods.service.ts, I have an array
[{
"category": "dogfood", "flavor": "chicken",
"category": "catfood", "flavor": "beef",
"category": "birdfood", "flavor": "sunflower",
"category": "dogfood", "flavor": "beef",
"category": "dogfood", "flavor": "chicken"
}]
then in my food.component.html I have my loop:
<ul>
<li *ngFor = "let food of foods">
<span>{{food.category}}</span>
</li>
</ul>
if I run it as such I get duplicate values of dogfood. what I ideally want is to only return a list with unique value. for instance, it should return:
- dogfood
- catfood
- birdfood
as dogfood has already been displayed. I know I need to add a *ngIf to the span tag but not sure what to put there or even if this is the correct place to do so.