Ionic version:
[ ] 1.x
[x] 2.x
I'm submitting a ...
[x] bug report
[ ] feature request
Current behavior:
When navigating out of a page with a Tabs component and coming back, the ionViewWillEnter is called on the page holding the tabs component, but not on the active tab.
Expected behavior:
This event should probably be fired on the active tab.
Steps to reproduce:
this.app.getRootNav().push(SomeOtherPage); Cordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.4
Ionic CLI Version: 2.1.18
Ionic App Lib Version: 2.1.9
Ionic App Scripts Version: 0.0.48
ios-deploy version: 1.8.6
ios-sim version: 5.0.8
OS: macOS Sierra
Node Version: v4.4.3
Xcode version: Xcode 8.2.1 Build version 8C1002
Sorry about not creating a Plunker, I am really in a rush this month.
Temporary work around
In the parent page that holds the Tabs component:
isFirstLoad = true;
ionViewDidEnter(){
if(!this.isFirstLoad){
if(this.tabs.getSelected()){
let t = this.tabs.getSelected();
let views = t.getViews();
let v = views[views.length-1].instance;
if(v.forceWillEnter){
v.forceWillEnter();
}
}
}
this.isFirstLoad = false;
}
In the child page (a Tab), I added this:
forceWillEnter = () => {
this.ionViewWillEnter();
}
I can confirm that it's still an issue in Ionic 2.1.0.
I think this is not just the tabs but happening to any nested nav. The ionViewWillEnter is called on the page that is directly under the nav that is going through a transition, but if that page contained a child nav, its active page's ionViewWillEnter does not get called.
Updating the issue.
version: 3.12.0
I'm navigating from ' TemplatePage' that is in tab navigation to another page using this.navCtrl.parent.parent.push('AddTemplate') and coming back to 'TemplatePage' with the default back button provided by ionic. I have a ionViewWillEnter() function in 'TemplatePage' with a log but that back action doesn't seem to trigger it. Upon changing tabs and coming back, it does fire.
The same problem here.
ionViewWillEnter() not triggering in the tab page only in the main page containing all the tabs when coming back from another view push from the tab.
is this fixed?
I have the same problem here, but I can get a workaround using:
this.appCtrl.getActiveNav().parent.parent
@Component({
selector: 'app-my-page',
templateUrl: './my-page.page.html',
styleUrls: ['./my-page.page.scss'],
})
export class MyPage {
ionViewWillEnter() {
console.log('ionViewWillEnter');
}
}
to
import { ..., OnDestroy } from '@angular/core';
@Component({
selector: 'app-my-page',
templateUrl: './my-page.page.html',
styleUrls: ['./my-page.page.scss'],
})
export class MyPage implements OnDestroy {
ionViewWillEnter() {
console.log('ionViewWillEnter');
}
ngOnDestroy(): void {
console.log('ngOnDestroy');
}
}
automatically "ionViewWillEnter" starts firing after leave TabsPage and enter on it again
working on Beta ionic 4
This issue has been automatically identified as an Ionic 3 issue. We recently moved Ionic 3 to its own repository. I am moving this issue to the repository for Ionic 3. Please track this issue over there.
If I've made a mistake, and if this issue is still relevant to Ionic 4, please let the Ionic Framework team know!
Thank you for using Ionic!
Issue moved to: https://github.com/ionic-team/ionic-v3/issues/159
Most helpful comment
Updating the issue.
version: 3.12.0
I'm navigating from ' TemplatePage' that is in tab navigation to another page using
this.navCtrl.parent.parent.push('AddTemplate')and coming back to 'TemplatePage' with the default back button provided by ionic. I have aionViewWillEnter()function in 'TemplatePage' with a log but that back action doesn't seem to trigger it. Upon changing tabs and coming back, it does fire.