Ionic 4. Alternative to NavParams

后端 未结 8 1715
灰色年华
灰色年华 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:29

    While Routing you can write like this:

    this.router.navigate(["/payment-details",{
      prev_vehicle_type: this.vehicle_type,
          prev_amt: this.amt,
          prev_journey:this.whichj
    }]);
    

    To get this parameters on the next page you can write:

    constructor(
    public router: Router,
    public activateroute: ActivatedRoute){
    this.activateroute.params.subscribe((data: any) => {
      console.log(data);
      this.vehicle_type = data.prev_vehicle_type;
      this.amt = data.prev_amt;
      this.whichj = data.prev_journey;
    
    });
    }
    

提交回复
热议问题