Anna F Anna F - 3 years ago 105
TypeScript Question

Delay for router in Angular2

I have this code, which have 2 functions:

will play the music (is implemented and it works)
leads to next page (it works also)

go_next() {
this.say(); // audio
this.router.navigate( ['app'], { queryParams: { 'part': this.part+1 } } ); //go to next page

But what I would like to do is to play music (it takes 5 sec) and then to go to the next could I implement this?..I guess, I have to implement some kind of
, but I can't find such parameter by

Answer Source

setTimeout(function, milliseconds) Executes a function, after waiting a specified number of milliseconds.

    setTimeout(() => {
        this.router.navigate(['app'], {queryParams: {'part': this.part + 1}})
      , 5000);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download