1
我試圖在成功刪除數據後重定向頁面。所以我把重定向router.navigate的訂閱數據部分。但它不工作,我也曾嘗試與ngZone也沒有任何反應。我也想展示成功的訊息。我怎樣才能表明這一點?router.navigate不起作用
沒有ngZone:
const rid = params['rid'];
this.roleSer.deleteRole(rid).subscribe(
data => { this.router.navigate(['viewroles']) },
error => { error }
);
});
與ngZone:
const vrid = this.route.params.subscribe((params: Params) => {
const rid = params['rid'];
this.roleSer.deleteRole(rid).subscribe(
data => { this.zone.run(()=>{
this.router.navigate(['viewroles'])
}); },
error => { error }
);
});
是什麼this.zone.run(() –
感謝?對於你的建議我已經試過了但是不行 –
你得到了什麼錯誤 –