Here is the HTML code I'm having trouble with:
<div *ngFor="let dates of the_list">
<p [ngStyle]="{'background-color': changeColor($event)}" [ngClass]="{ 'text-white':(the_list.indexOf(dates))>4 }">{{dates}}</p>
</div>
The corresponding TypeScript function is:
changeColor(event: any){
this.temp=(<HTMLInputElement>event.target).value;
if(this.the_list.indexOf(this.temp)===5)
{
return 'blue'
}
else
{
return ''
}
}
An error message pops up saying: ERROR TypeError: Cannot read property 'target' of undefined.
I wonder, is it not allowed to pass $event as a parameter in this case?