Issue
I am able to get a single param through route like page1/id1
in Ionic 5.
If I want to get multiple parameters for a module, how do I do that?
Solution
In app-routing.module.ts, modify the path to-
{
path: 'page1/:id1/:id2',
loadChildren: () => import('./pages/page1/page1.module').then(m => m.Page1PageModule)
},
In the page through which you want to access this page, say for instance page0.page.html include-
<ion-item button [routerLink]="['/', 'page1', id1,id2]" >Go to Page1 </ion-item>
In page1.page.ts , in order to access these params, inclde the following in ngOnInit -
import { ActivatedRoute, Router} from '@angular/router';
..
constructor(private route : ActivatedRoute, private router : Router){}
ngOnInit() {
this.route.paramMap.subscribe(params => {
let id1 = params.get('id1');
let id2 = params.get('id2');
});
}
Answered By - Leena
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.