Better use observables
this.sub = Observable.interval(10000)
.subscribe((val) => { console.log('called'); });
to stop it use
this.sub.unsubscribe();
Make sure to import interval
with
import 'rxjs/add/observable/interval';
More Related Contents:
- Ionic 2 – global NavBar for the app
- Ionic 2 Form goes up when keyboard shows
- Ionic – Horizontal scroll tab for Categories [duplicate]
- Page is part of the declarations of 2 modules: Error in ionic build prod
- Use nav.push with side menu in ionic 2
- Angular 2 + Ionic 2: Detect if an object was modified
- Ionic2/Angular2 – Read a custom config file
- How to use angular 2 service with Ionic 2?
- Property ‘files’ does not exist on type ‘EventTarget’ error in typescript
- Getting “Uncaught (in promise): TypeError: Object(…) is not a function” Error from Ionic-native VideoEditor Plugin
- No provider for AngularFireDatabase, AngularFireAuth
- Cannot read property of ‘xxx’ of undefined
- How to display the app version in Angular?
- access SASS values ($colors from variables.scss) in Typescript (Angular2 ionic2)
- Http.get() working but not working in build(Release/Debug) in Ionic 4
- Merging http observables using forkjoin
- Cannot read property ‘native-element’ of undefined
- How can I select an element in a component template?
- Equivalent of $compile in Angular 2
- How to dynamically add a directive?
- angular 2 sort and filter
- Angular2 – FormControl Validation on blur
- Angular4 Exception: Can’t bind to ‘ngClass’ since it isn’t a known property of ‘input’
- Multiple canActivate guards all run when first fails
- TS2531: Object is possibly ‘null’
- Custom ExceptionHandler change detection lag
- Trigger update of component view from service – No Provider for ChangeDetectorRef
- TypeError: You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable
- Rxjs Retry with Delay function
- What is the meaning of question mark in expressions in Angular 2?