Send data through routing paths in Angular

前端 未结 6 1391
无人共我
无人共我 2020-11-22 08:52

Is there anyway to send data as parameter with router.navigate? I mean, something like this example, as you can see the route has a data parameter, but doing this it\'s not

6条回答
  •  我在风中等你
    2020-11-22 09:40

    In navigateExtra we can pass only some specific name as argument otherwise it showing error like below: For Ex- Here I want to pass customer key in router navigate and I pass like this-

    this.Router.navigate(['componentname'],{cuskey: {customerkey:response.key}});
    

    but it showing some error like below:

    Argument of type '{ cuskey: { customerkey: any; }; }' is not assignable to parameter of type 'NavigationExtras'.
      Object literal may only specify known properties, and 'cuskey' does not exist in type 'NavigationExt## Heading ##ras'
    

    .

    Solution: we have to write like this:

    this.Router.navigate(['componentname'],{state: {customerkey:response.key}});
    

提交回复
热议问题