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

前端 未结 4 566
轻奢々
轻奢々 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:02

    The timer function now need to be imported directly from rxjs library, Below works fine.The message 'fired' will be seen in console after 10 seconds.

    import { timer } from 'rxjs';
    
    const numbers = timer(10000);
    numbers.subscribe(any => console.log('fired'));
    

    Please see this link for more details:https://rxjs-dev.firebaseapp.com/api/index/function/timer

提交回复
热议问题