I'm from Java background. There we have multithreading to handle these kind of behaviors. I need help with Angular 6. When my component loads. Some simple style is to be applied on that. But after 5 seconds on click of button the style should go away.
Template:
<div [class.error-warning]="applyStyle">
<select>
<option>Apple</option>
...
</select>
</div>
<button (click)="removeStyle()">Remove</button>
Typescript:
applyStyle: boolean=true;
removeStyle() {
//after 5 seconds
this.applyStyle=false;
}
CSS:
.error-warning {
border: 2px solid red;
}
I tried sleep
here but it blocked the entire dropdown
for 5 seconds. Please help me out. Here is the stackblitz.