Ionic 4. Alternative to NavParams

后端 未结 8 1712
灰色年华
灰色年华 2021-01-06 10:55

I am using ionic 4. It does not accept to receive data using navparams. Here is my sender page method:

  //private route:Router
  gotoFinalView(intent) {
            


        
8条回答
  •  不知归路
    2021-01-06 11:25

    The item, icon and title variables you want to send should be written in the state in this way.

    this.nav.navigateForward('/myUrl', {
            state: {
              'items': this.substances,
              'icon': ICONS.substance,
              'title': 'Etken Maddeler'
            }
          });
    

    We take incoming variables this way.

    //receive
    constructor(
          protected route: ActivatedRoute,
          protected router: Router,
      ) {
        this.selectedItem = null;
        this.route.paramMap.subscribe(params => {
          let st = this.router.getCurrentNavigation().extras.state;
          if (st) {
            this.selectedItem = st.items;
          }
        });
      }
    

提交回复
热议问题