I need to just get unique category from http response which Im getting as Json from API Here is my Code
export class FoodList implements OnInit{
foodList:Food[]=[];
p:Food[]=[];
//name:string;
constructor( private foodS:FoodService){}
ngOnInit(){
this.foodS.getAll().subscribe(allfood =>this.foodList=allfood);
}
foodList[]
giving me values but all with duplicate category I need to display only unique category .
<div class="list-group">
<a href="#" class="list-group-item active">
All
</a>
<div *ngFor="let food of foodDetails ">
<a href="#" class="list-group-item">{{food.category}} </a>
</div>
</div>
service :
constructor( private http : HttpClient ){}
getAll(): Observable<Food[]>{
return this.http.get<Food[]>(this._url)
}
Please suggest me any idea or how I can achieve it? Thanks