There is multiple ways to pass a parameters from a page to another in Ionic v4 / Angular 7.2+:
1. Using Extras State (new since Angular 7.2) - Recommanded
Simple and clean
// original page
let navigationExtras: NavigationExtras = { state: { foo: this.foo } };
this.router.navigate(['destination-path'], navigationExtras);
// destination page
constructor(private route: ActivatedRoute, private router: Router) {
this.route.queryParams.subscribe(params => {
if (this.router.getCurrentNavigation().extras.state) {
this.foo= this.router.getCurrentNavigation().extras.state.foo;
}
});
}
2. Use a service and a resolver
Does not fecth the data but a bit heavy.
Store the data into a service and pass a resolver using the router
3. Using object's id (not recommanded)
If your object is stored, you can pass the id in the url and fetch it again.
It will slows the application, implies that the object is stored somewhere and may increase networks issues (if not stored localy)
4. Using query params (not recommanded)
By stringyfing your object: See @Tahseen Quraishi's answer
Only few informations can be passed and the URL is hideous
Some examples here
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…