This is an simple example, real problem is more complex.
cars: string[] = ['audi', 'opel', 'mazda'];
isAudi: boolean = false;
isOpel: boolean = false;
checkCar(car):void {
if(car == 'audi'){
this.isAudi = true;
}
}
<div *ngFor="let car of cars" (validationCheck)="checkCar(car)">
<p *ngIf="isAudi">Audi: {{car}}</p>
<p *ngIf="isOpel">Opel: {{car}}</p>
</div>
validationCheck
is directive that triggers function for every item in array.
This will output:
Audi: audi
Audi: opel
Audi: mazda
I want only to show:
Audi: audi
*ngIf="car == 'audi'"
is out of the question because of real complexity of object.
Ps. if you want to downvote a question, give me a good explanation why question does not show research effort or its unclear or not useful, thx