私は5秒ごとにGET要求を送信するタイマーを作成しようとしていますが、私はそれを行うことができますが、私は別のページ(ルーティング)私はngOnDestroyを追加しようとしましたが、私は "退会" 方法Angular2:タイマーの作成と破棄
import {Component, OnInit, OnDestroy} from '@angular/core';
import {Observable} from 'rxjs/Rx';
@Component({
templateUrl: 'app/pages/CurrentRuns/currentruns.component.html'
})
export class CurrentRunsComponent implements OnInit, OnDestroy {
private timer;
ticks=0;
ngOnInit() {
this.timer = Observable.timer(2000,5000);
this.timer.subscribe(t => this.tickerFunc(t));
}
tickerFunc(tick){
console.log(this);
this.ticks = tick
}
ngOnDestroy(){
console.log("Destroy timer");
}
}
を持っていない、 "rxjs": "5.0.0-beta.12"
こんにちは、私は、一つの問題を持っています。 –