Angular 2 - 无法停止Observable(unsubscribe()抛出undefined)

时间:2017-06-13 16:04:31

标签: angular

我想退出视图并推送到下一个视图后执行unsubscribe()。但是,this.updateRoute.unsubscribe()会引发undefined任何理由?

   ngOnInit(){
   //The following executes each 10 seconds
    let updateRoute = Observable.timer(0,10000);
    this.updateRoute = updateRoute.subscribe(update =>{
    this.updateRouteTaken(this.driverLocation)
     })
    }


ngOnDestroy(){
//this throws undefined
this.updateRoute.unsubscribe();
}

0 个答案:

没有答案