Send data through routing paths in Angular

前端 未结 6 1344
无人共我
无人共我 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:32

    @dev-nish Your code works with little tweaks in them. make the

    const navigationExtras: NavigationExtras = {
      state: {
        transd: 'TRANS001',
        workQueue: false,
        services: 10,
        code: '003'
      }
    };
    

    into

    let navigationExtras: NavigationExtras = {
      state: {
        transd: '',
        workQueue: ,
        services: ,
        code: ''
      }
    };
    

    then if you want to specifically sent a type of data, for example, JSON as a result of a form fill you can send the data in the same way as explained before.

提交回复
热议问题