Search code examples
angulartypescriptangular-ui-router

Use same children under two different parents in Angular 8


I have 2 different ways to access some pages, a view mode and an edit mode. so I would like to have the following two URLs for those options (all the pages are quals, they will be handled by a parameter - edit or not):

profile/first-tab/1 (for viewing)

profile/first-tab/edit/1 (for editing)

The profile is the parent, and beneath that are 5 children (first-tab, second-tab...)

How do I configure routing for that the best way?

Thanks very much in advance :-)


Solution

  • You can change your routing like this and have the same component for both routes

     const routes: Routes = [
    
      { path: 'profile/first-tab/1', component: SomeComponent },
      { path: 'profile/first-tab/edit/1', component: SomeComponent }
    ];