bug: setPages and insertPages do not expose proper types
See original GitHub issueFeature Request
Ionic version:
[x] 5.x
Describe the Feature Request Hello,
I have a ion-nav in a separate section of my app (independant of the Angular routing that I’m using for the main content of my app). And I would like to INSERT a stack of pages into this ion-nav at a specified index, the functions insertPages and setPages seems perfect but lacks documentation (also see https://github.com/ionic-team/ionic-docs/issues/1478) on how to pass props to components.
Describe Preferred Solution
To push a view one by one it’s :
@ViewChild("nav") nav: IonNav;
ngOnInit(): void {
await this.nav.push(MyNewComponent, { input1: "value", input2: "value" });
}
And I would like to do something like :
@ViewChild("nav") nav: IonNav;
ngOnInit(): void {
// Index 1
await this.nav.insertPages(1, [
{ component: MyNewComponent, componentProps: { input1: "value", input2: "value" } },
{ component: MyNewComponent, componentProps: { input1: "value2", input2: "value2" } },
{ component: MyNewComponent, componentProps: { input1: "value2", input2: "value3" } }
]);
}
But this is currently not possible … It says incompatible with type NavComponent which is ComponentRef | ViewController
. So I can do the following to have 0 errors but HOW to pass componentProps
as well ??
@ViewChild("nav") nav: IonNav;
ngOnInit(): void {
// Index 1
await this.nav.insertPages(1, [ MyNewComponent, MyNewComponent, MyNewComponent ]);
}
I would appreciate any help …
doc : https://ionicframework.com/docs/api/nav cross-reference : https://forum.ionicframework.com/t/how-to-use-ionnav-insertpages/192561
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (7 by maintainers)
Fixed setPages as well - thanks 👍
Glad it works! Ah right I forgot to export
NavComponentWithProps
. I will make sure that gets updated in my PR.