Angular Nested Routing with modules

Published

I wanted to have routes of products.
First I wanted to have a list route that looks like:
/products. For its view details, it should look like /products/:id. For creating new, it should look like /products/new.

Its working well BUT the problem is the sidemenu doesn’t highlight the view details and the creating new page. Which means it isn’t on the child?

Main Route

{
    path: 'products',
    loadChildren: () => import('@app/products/products.module').then((m) => m.ProductsModule),
},

Child Route

{
    path: '',
    children: [
      {
        path: '',
        component: ProductsListComponent,
      },
      {
        path: 'new',
        component: ProductsCreateComponent,
      },
      {
        path: ':id',
        component: ProductsDetailComponent,
      },
    ],
  },

Source: Angular Questions

Published
Categorized as angular, angular-router, angular-routing Tagged , ,

Answers

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq