Here's the code snippet I'm working with:
import { Component, ViewChild } from '@angular/core';
import { IonicPage, NavController, Nav, App, Tabs} from 'ionic-angular';
@Component({
templateUrl: 'tabs.html'
})
export class TabsPage {
tab1Root = HomePage;
tab2Root = AboutPage;
tab3Root = ContactPage;
app: App;
constructor(app:App, nav: Nav) {
this.app = app;
console.log('=======================');
this.app.viewDidLoad.subscribe((view) => {
console.log(view.instance.constructor.name);
});
}
}
Initially, the output is:
=======================
TabsPage
HomePage
When I navigate to a different tab:
AboutPage
And another tab:
ContactPage
However, when I return to the same tab, the events seem to stop working. Why is this happening? Any assistance would be greatly appreciated
In Angular, a similar module {Router} is available from '@angular/router'; and it works fine, like so:
router.events.forEach((event) => {
if(event instanceof NavigationEnd && event.url == '/notes') {
}
});
Navigating through child routes always works as expected. How can I ensure Ionic functions similarly to this behavior?