Z
Z
zlodiak2019-06-19 21:17:45
Angular
zlodiak, 2019-06-19 21:17:45

How to fix nested routing?

Please help me fix the routing. I have 3 components: app, mainLayout, hello. I would like to make the template of the app component contain only: and the routes would be described by the following rule:
<router-outlet></router-outlet>

const routes: Routes = [
  {
    path: '',
    component: MainLayoutComponent,
    children: [
          {
            path: 'hello',
            component: HelloComponent
          }
    ]
  } 
];

That is, when entering the application, the user would see the mainLayout component template, and if he added /hello to the address bar, he would see the hello component template.
I partially implement it here.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
2
210mev, 2019-06-19
@210mev

const routes: Routes = [
  { path: '', component: MainLayoutComponent },
  { path: 'hello', component: HelloComponent },
];

So it doesn't work?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question