Somebody can tell me if is possible to open a child route in a new view instead of opening right under it? If so how and how to comeback to the father route previous state of navigation?
Asked
Active
Viewed 32 times
2 Answers
0
Instead of
const routes: Routes = [
{ path: 'first', component: ExampleComponent, children: [
{ path: 'second', component: Example2Compoennt, }
] }
];
Do:
const routes: Routes = [
{ path: 'first', component: ExampleComponent },
{ path: 'first/second', component: Example2Compoennt },
];

Ron Rofe
- 738
- 1
- 9
- 25
0
It's good to use children
, because if you want to use some guard
s it's gonna work for all children routes, it's very useful when you're creating authenticated routes.
Example:
const routes: Routes = [
{
path: 'first',
children: [
{ path: '', component: FirstComponent },
{ path: 'second', component: SecondComponent },
{
path: 'third',
canActivate: [YourGuard],
children: [
{ path: '', component: ThirdComponent },
{ path: 'another-route', component: FourthComponent },
]
}
],
}
];

Damian Plewa
- 1,123
- 7
- 13