Reputation: 2991
I am trying to set a delay for a display in my app. After I run the program, the message is displayed correctly and stays instead of displaying for just 4 seconds. This my delay function. What could be wrong
display(){
this.foodservice.getFood()
.subscribe(data =>
{
delay (4000)
this.display =""
});
}
Upvotes: 33
Views: 101302
Reputation: 1363
The function you are looking for is called setTimeout.
display(){
this.foodservice.getFood()
.subscribe(data => {
setTimeout(()=>{ this.display = "" }, 4000)
}
}
Upvotes: 78