I'm trying to use the interval method of an observable but I keep getting the error
Property 'interval' does not exist on type 'Observable<any>'.
I added these imports:
import "rxjs/Rx"; import "rxjs/add/observable/interval"; import "rxjs/observable/IntervalObservable";
You need to import the Observable
class this way to be able to use the interval
method:
import {Observable} from 'rxjs/Rx';
or
import {Observable} from 'rxjs/Observable'; import 'rxjs/add/observable/interval';
If you want to create an interval
(Observable) with rxjs v6.2.1
:
import { interval } from 'rxjs'; // instead of: // import { Observable } from 'rxjs/Observable'; // import 'rxjs/add/observable/interval'; const counter = interval(1000); // instead of: // const counter = Observable.interval(1000);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With