Typescript sleep

前端 未结 7 559
后悔当初
后悔当初 2020-11-30 20:02

I\'m developing a website in Angular 2 using Typescript and I was wondering if there was a way to implement thread.sleep(ms) functionality.

My use case

7条回答
  •  攒了一身酷
    2020-11-30 20:30

    This works: (thanks to the comments)

    setTimeout(() => 
    {
        this.router.navigate(['/']);
    },
    5000);
    

提交回复
热议问题