Change a single route parameter on the current route in Angular 2

前端 未结 5 1028
慢半拍i
慢半拍i 2021-02-05 03:32

Is it possible to change a single route parameter in the current route, while keeping all the other parameters? This is for use in a paging component, which will route to a new

5条回答
  •  长情又很酷
    2021-02-05 04:34

    use if statement or switch case to push parameters

    if(yourchild == child1){
        params = { 
          parameter1: parameter1, 
          parameter2: parameter2,
        }
    } else (yourchild == child2){
        params = { 
          parameter1: parameter1, 
          parameter2: parameter2,
          parameter3: parameter3
        }
    }
    this.router.navigate([`/yourparent/${yourchild}`], { queryParams: params });
    

提交回复
热议问题