C
C
Coder3212016-10-24 20:10:49
JavaScript
Coder321, 2016-10-24 20:10:49

How to make nested router-outlet in Angular 2?

You need to do something like this.
f70920c0a7fe4cfe9c9bc7c47df0aa06.png
That is, the root component will have only a router-outlet, the next "First template" will have to have its own sidebar and body, in the body there is another router-outlet. "first" and "second" must switch in the body of "first template". The question is how to do this? If you do it without the "first template" intermediate component, then there are no problems, but if you do it, I don't know how.
Routes for "First Parent" and its descendants "first" and "second" I prescribe something like this.

const routes: Routes = [
  {
    path: '',
    component: FirstParentComponent,
    children: [
      {
        path: '',
        component: FirstComponent
      },
      {
        path: 'second',
        component: SecondComponent
      }
    ]
  }
];
export const Routing: ModuleWithProviders = RouterModule.forChild(routes);

How to write routes for "First Template"?
I will be grateful for help)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Zuev, 2016-10-25
@yurzui

Maybe I misunderstood the meaning of the task, but try to look at this example
https://plnkr.co/edit/bvk28mqXwfbg8YaZPzCD?p=preview
It is better to click on view in a separate window to clearly see the
urls Child routes can be moved to Routing modules and loaded asynchronously .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question