2017-06-20 82 views
2
returnToPreviousPage(){ 
     this.router.navigate([this.returnUrl], { queryParams: { customerId: this.caId } }); 
    } 

我有這樣的方法,所以我想要的是,當用戶返回到上一個頁面,清除queryParams。任何建議我該怎麼做?如何在重定向後刪除queryParms?

回答

0

使用三元:

returnToPreviousPage(){ 
     this.router.navigate([this.returnUrl], { queryParams: yourBoolean ? { customerId: this.caId } : null }); 
    } 

哪裏yourBoolean可以是任何條件

UPDATE

returnToPreviousPage(){ 
     this.router.navigate([this.returnUrl], yourBoolean ? { queryParams: { customerId: this.caId } } : null); 
    } 
+0

它西港島線不清晰PARAMS重定向後,將只發送客戶ID依賴於布爾。我需要始終發送該參數,但在此之後將其刪除 – None

+0

否,它將清空您的queryParams。但看到我的更新,如果你不想發送任何queryParams。 – trichetriche

+0

無法讀取空 – None