Hi, I’m stuck in trying to pass a parameter to a child page of a tab (ionic 4):
tabs.page.html
<ion-tab label="Settings" icon="settings" href="/tabs/(settings:settings)">
<ion-router-outlet name="settings"></ion-router-outlet>
</ion-tab>
tabs.router.module.ts
const routes: Routes = [
{
path: 'tabs',
component: TabsPage,
children: [
....
{ path: 'settings/:func', outlet: 'settings', component: SettingsPage },
{ path: 'settings', ... },
]
...
];
settings.page.ts
export class SettingsPage implements OnInit ... {
private routeSub: Subscription;
constructor( private activatedRoute: ActivatedRoute) {}
ngOnInit() {
console.log('Calling this without parameter. OK.');
this.routeSub = this.activatedRoute.params.subscribe(params => {
console.log('This is called for the first time the settings tab loads and never again.');
if (params['func'] == 'myFunc') {
console.log('You cant see me :-(');
}
})
}
After the first ngOnInit, I navigate to another page and return from that page with:
this.router.navigateByUrl('/tabs/(settings:settings/myFunc');
I’d expect to see “You can’t see me :-(”. I am trying for some days now and hope the answer isn’t too easy.
Thanks for your help.