I am applying color to div element and i am changing color in cycle as follow
toogleColor()
{
if(this.color=='blue')
{
this.color="red"
this.fontcolor='white'
return
}else if(this.color=='red'){
this.color='white'
this.fontcolor='black'
return
}else if(this.color=='white'){
this.color='blue'
this.fontcolor='white'
return
}
}
and I have setStyle() function as follow:
setStyle(){
this.toogleColor()
return {
'background-color':this.color,
'height':'382px'
}
}
In my component html I binded style as follow:
<div [ngStyle]="setStyle()" *ngFor="let element of array1">
But i am not Getting expected color cycle because setStyle() funnction is called 4*number of element in array