On refreshing the child page I want the page to redirect to it parent's parent page in Angular

27 Views Asked by At
import { Parent1Component } from './parent1-shell.component';

const routes: Routes = [
  {
    path: 'children1',
    component: children1,
    children: [
      {
        path: 'subchildren1',
        component: subchildren1,
      },
      {
        path: 'subchildren2',
        component: subchildren2,
      }        
    ],
  },
  {
    path: 'children2',
    component: children2,
    children: [],
  },
  {
    path: 'children3',
    component: children3,
    children: [],
  },
  {
    path: '',
    redirectTo: 'children2',
    pathMatch: 'full',
  },
  {
    path: '**',
    redirectTo: 'children2',
    pathMatch: 'full',
  },
   
];

@NgModule({
  imports: [RouterModule.forChild(routes,)],
  exports: [RouterModule],`your text`
})
export class Parent1GyncRoutingModule {}

When I refresh the page:subchildren1,I want the redirection to parent 1 but now its in page: subchildren1 with no data or page is blank, above given code is the parent 1 routing module. I have all the navigation in auth.service. I am also using authguard.

I tried using { onSameUrlNavigation: 'reload' } It didnt work.

0

There are 0 best solutions below