setTimeout not working with Angular5

Issue

this.fetchRequests(this) gets executed as soon as the view is initialized instead of waiting for 20 seconds.

I am aware in the older versions we have to use the wrapper but in the new versions those are not required I guess. Any help on this would be helpful.

ngAfterViewInit() {
    setTimeout(()=>{
        this.fetchRequests(this);
    }), 10000;
}

Solution

I think you write the wrong syntax
this code

setTimeout(()=>{
    this.fetchRequests(this);
}), 10000;

should be like this

setTimeout(()=>{ this.fetchRequests(this); },1000);

Answered By – mostafa tourad

Answer Checked By – Pedro (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.