我想退出视图并推送到下一个视图后执行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();
}