ionViewWillEnter is not triggering on tabs

hello there, im using ionic angular for my mobile app, i created page for tabs, unitab.page.ts, there is the unitab-routing-module.ts

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { UnitabPage } from './unitab.page';
import { DvirPageModule } from '../dvir/dvir.module';
import { DvirPage } from '../dvir/dvir.page';

const routes: Routes = [
  {
    path: '',
    component: UnitabPage,
    children: [
      {
        path: 'hos',
        loadChildren: () =>
          import('../hos/hos.module').then((m) => m.HosPageModule),
      },
      {
        path: 'dvir',
        component: DvirPage,
      },
      {
        path: 'inspection',
        loadChildren: () =>
          import('../inspection/inspection.module').then(
            (m) => m.InspectionPageModule
          ),
      },
      {
        path: 'others',
        loadChildren: () =>
          import('../others/others.module').then((m) => m.OthersPageModule),
      },
      {
        path: '',
        redirectTo: '/unitab/hos',
        pathMatch: 'full',
      },
    ],
  },
  {
    path: '',
    redirectTo: '/unitab/hos',
    pathMatch: 'full',
  },
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule],
})
export class UnitabPageRoutingModule {}

the problem is that on dvir page I move to edit-dvir page, make some changes, and when I save and use this.navCtrl.navigateBack('/unitab/dvir');, on dvir page doesn’t trigger either ngOnInit, ionViewWillEnter, ionViewDidEnter, but at the same time, in unitab page ts ngOninit is working, what could be the problem and how to solve it?
I need to trigger ionViewWillEnter, when i navigateBack to it not by clicking tabs, but using this.navCtrl.navigateForward(ā€˜/insert-dvir’);

sorry for my English, hope u understood me!

yah, you can achive this scenario by using the route params in the your components.ts file here is the code it will trigger when ever come back to this page.

import { Router, ActivatedRoute } from ā€œ@angular/routerā€;
import { Subscription } from ā€œrxjsā€;

paramsSubscription: Subscription;

constructor(private route : ActivatedRoute){}

ngOnInit() {
console.log(ā€˜inside on-init’);
this.paramsSubscription = this.route.params.subscribe(params=>{
console.log(ā€˜inside on-init again’);
// it will trigger when ever come back to this page
});
}

1 Like