Clear all queryParams with new Router v3 Angular2

后端 未结 3 1256
栀梦
栀梦 2021-01-17 08:00

I\'m trying to figure out how to use the Angular2 router navigation (router 3.0.0-alpha.7) with query parameters.

I can easily navigate to a route with a queryParam

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-17 08:54

    I struggled with this as well. You would expect the router to clear query params by default when navigating to another route...

    You can do either

    this._router.navigate(['/route1'], {queryParams: {}});
    

    or

    this._router.navigateByUrl('/route1');
    

    or when using routerLink:

     Applications
    

提交回复
热议问题