Angular 6 - run method in service every 10 seconds

前端 未结 7 1958
难免孤独
难免孤独 2020-12-14 02:52

I have this service using HttpClient to get some data :

checkData() {
    return this.http.get(\'my url\');
}

The on the footer component I

7条回答
  •  隐瞒了意图╮
    2020-12-14 03:44

    You can use the setInterval which is quite simple

    setInterval(console.log('hi'), 10000);
    

    This runs for every 10 secs

提交回复
热议问题