Reputation: 3381
There's a basic DOM:
main
- child A :goBack()
-- subChild A :*
- child B :goBack()
From the app.component.html
I propagate a footer
element to all DOM children.
What I wonder is, why does the Back
button not appear on the subchild A page?
See stackblitz.
Upvotes: 0
Views: 45
Reputation: 60357
You have to create subchild as an actual child route. Otherwise it will be handled as any other route and completely replace the <router-outlet>
tag, in this case the ChildComponent
.
const routes: Routes = [
{ path: '', component: MainComponent },
{
path: ':child', component: ChildComponent, children: [
{ path: 'subChildA', component: SubChildComponent }
]
},
];
Also, you need a second <router-outlet>
tag within the template of your ChildComponent
where the subroutes (subchildren) are supposed to be rendered.
Have a look at the modified stackblitz.
Upvotes: 1
Reputation: 609
You need to create child route for that. Check this edit
https://stackblitz.com/edit/angular-oupmd9
specially app-routing.module.ts
Upvotes: 0