我的页面Observable.timer
上有一个计时器,当它结束时会触发nav.push
到另一个页面。但是,当我单击应用程序或硬件后退按钮内的后退按钮时,Observable.timer
会触发nav.push
。即使返回导航堆栈,如何使计时器倒计时?
countDown: any;
counter = 1*10;
tick = 1000;
status:any;
constructor(public modalCtrl: ModalController, public navCtrl: NavController, public navParams: NavParams, public storage: Storage, public viewCtrl: ViewController) {
this.startTimer();
}
startTimer() {
this.countDown = Observable.timer(0, this.tick)
.take(this.counter)
.map(() => --this.counter).finally(() => this.endTimer());
//this.countDown.subscribe(() => { });
}