While using ng-for loop, I want to add class to item, only if the id of the item exists in some other objects list.
I tried something like this:
<div *ngFor="let p of products" [class.Flag]="favoriteList.some((item)=> item.Id == p.id)"> </div>
or this:
<div *ngFor="let p of products" [ngClass]="favoriteList.some((item)=> item.Id == p.id) ? 'Flag': ''"> </div>
But it's not compiling.
note that the "favoriteList" may be load to the page after "products".
Any idea how can I do this?
thanks!