send data in navigation using ionic5

https://ionicacademy.com/pass-data-angular-router-ionic-4/





send page:
import { Router, NavigationExtras } from '@angular/router';
let paymentDetails = {
amount: this.ElectricityForm.value.Amount,
provider_code: this.providercode,
connection_provider: this.ElectricityForm.value.SelectBoard,
account_number: this.ElectricityForm.value.ConsumerNO,
bill_type: "payment",
type: "electric",
selectstate:this.ElectricityForm.value.SelectState,
statecode:this.statecode
}
let navigationExtras: NavigationExtras = {
queryParams: {
special: JSON.stringify(paymentDetails)
}
};
this.router.navigate(["/paybillpayment-options"],navigationExtras)

receive page::


import { ActivatedRoute, Router } from '@angular/router';
constructor(private route: ActivatedRoute, private router: Router) {
this.route.queryParams.subscribe(params => {
if (params && params.special) {
this.data = JSON.parse(params.special);
console.log(this.data)
}
});

Comments

Popular posts from this blog

Your app currently targets API level 27 and must target at least API level 28 to ensure it is built on the latest APIs optimized for security and performance. Change your app's target API level to at least 28

ionic project creation

change root user in ubuntu