I have div class alert.
<div class="alert" *ngIf=alert>
<h1>Copied</h1>
</div>
I want to show this div for 3 sec. Initially It will be hidden and after clicking a button I run a function and then I change the value to true and then it become visible. All the thing is happening. But When I am running a setTimeOut() function and after 3 sec I want to make the div invisible again that is not working.
alert; //the value i am using to hide the div
//after clicking the function I am running the function
copying() {
this.clipboard.copy(this.currentCode);
this.alert = true;
setTimeout(function() {
this.alert = false;
// the alert value is being change to false but the div is not hiding.
}, 3000)
}