@ZaLiTHkA wrote:
Greetings,
I’m building an Ionic 4 Angular app that has tabs as the initial view, where the main tab provides the means to navigate to a component inside a lazy-loaded module. I would like to run some custom logic inside this initial main tab component whenever it becomes the currently active page, which I’ve got working for all scenarios except when the app navigates back from the “Detail” component.
For reference, the routes defined in my main
app-routing.module.ts
are as follows:[ { path: '', redirectTo: '/tabs/home', pathMatch: 'full' }, { path: 'tabs', component: TabsPage, children: [ { path: 'home', component: HomePage } ] }, { path: 'detail', loadChildren: './detail/detail.module#DetailPageModule' } ]
…and I’m currently navigating from
HomePage
toDetailPage
(obviously, withinDetailPageModule
) using a button that calls the following function:viewDetail(data: CustomData) { this.navCtrl.navigateForward('detail', { state: data }); }
The
data: CustomData
part doesn’t affect my current issue directly, but I’m leaving it in the snippet to make it clear that I need to pass data along when navigating toDetailPage
…As a quick test, I implemented all of the Ionic 4 and Angular 8 lifecycle hooks in both the
HomePage
andDetailPage
components with a simpleconsole.log()
call so I could inspect the behaviour while I navigated around my app, but I cannot find anything that triggers inside myHomePage
component when I navigate back from theDetailPage
component…I’ve searched for posts from other people with the same issue, found a few that are really close, but I couldn’t glean any knowledge from those posts/issues/articles that helped me in any way.
I’ve also tried to make use of a
static
method inHomePage
that I can call from a lifecycle hook inDetailPage
, but this doesn’t give me access to any of the methods I’ve defined inHomePage
, so that doesn’t work for me.Is there anything I can do with the current app structure to achieve this? Do I perhaps need to structure my app components differently to create a scenario in which I can detect this navigation? If so, what would you suggest?
Posts: 1
Participants: 1