Angular 2 Kids Routes

I used the angular-cli tool to create my routes. It creates a folder with + in front of it, i.e.

  • +dashboard
  • +document

I cannot figure out how to create a child route using the angular-cli tool. It doesn’t really matter, but I would prefer to accept an agreed agreement in my application structure to describe the children's route.

So what should I do?

I put a folder under the parent route, like this

  • app\+document\+chapter

Is it better to do this?

  • app\+document
  • app\+chapter

Also, I got a little confused about the routes in general. I understand that there is an obsolete route and a new route. I think I'm using the new system since it was generated using the angular-cli tool. Anyway, I set several levels of child routes. And I was wondering if that looks legal.

@Routes([
  { path: '/', component: DashboardComponent },
  { path: '/document/:id', component: ReaderComponent,
      children: [
          { path: '', redirectTo: 'chapter/0', pathMatch: 'full' },
          { path: 'chapter/:id', component: ChapterComponent,
            children: [
              { path: '', redirectTo: 'para/0', pathMatch: 'full' },
              { path: 'para/:id', component: ParagraphComponent }
           ]}
      ]
  }
])

, http://my-url/document/1 http://my-url/document/1/chapter/0/para/0. ? , .. redirectTo .

, , "",

+4

Source: https://habr.com/ru/post/1649085/


All Articles