In angular 2 how to preserve query params and add additional query params to route

后端 未结 4 862
一生所求
一生所求 2020-12-29 22:00

For example I am on route /cars?type=coupe and I want to navigate to the same endpoint with additional query params (but keeping existing one). I am trying some

4条回答
  •  死守一世寂寞
    2020-12-29 22:45

    In Angular 4+, preserveQueryParams have been deprecated in favor of queryParamsHandling. The options are either 'merge' or 'preserve'.

    In-code example (used in NavigationExtras):

    this.router.navigate(['somewhere'], { queryParamsHandling: "preserve" });
    

    In-template example:

    
    

提交回复
热议问题