Error: Property timer doesn't exist on type typeof Observable

前端 未结 4 625
轻奢々
轻奢々 2021-02-07 11:40

The code is below

import {Component} from \'angular2/core\';
import {Observable} from \'rxjs/Rx\';

@Component({
selector: \'my-app\',
template: \'Ticks (every s         


        
4条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-07 12:09

    If all you need is a timer, you could use this too:

    setInterval(() => {
          this.callNecessaryMethod();
        }, this.intervalInMilliSeconds);
    

    This is the function prototype:

    function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer (+2 overloads)
    

提交回复
热议问题