How do I call a function in every 10 seconds in Angular 2?

前端 未结 4 1991
没有蜡笔的小新
没有蜡笔的小新 2021-01-14 11:23

How do I call a function in a set Time interval in Angular 2. I want it to be called/Triggered at specific time intervals(for eg 10 secs). For Eg: ts File

nu         


        
4条回答
  •  无人及你
    2021-01-14 12:05

    Observable.interval(10000).takeWhile(() => true).subscribe(() => this.function());

    infinite loop where every each 10 seconds function() is being called

提交回复
热议问题