如何在重定向后删除queryParms?

时间:2017-06-20 07:27:01

标签: angular

256x256

我有这个方法所以我想要的是当用户返回上一页时,清除queryParams。任何建议我怎么能这样做?

1 个答案:

答案 0 :(得分:0)

使用三元:

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

yourBoolean可以是任何条件

<强>更新

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