vim
vim

Reputation: 84

How to define angular routes for children pages with query params in app-routing.module.ts?

const routes: Routes = [   { path: '', component: DraftAnalysisHomeComponent },   { path: 'nfldraftanalysis', component: DraftAnalysisHomeComponent },   {
    path: 'nfldraftanalysis/averagegrades',
    component: AverageGradeComponent,
    children: [
      {
        path: '?year=:year&teamname=:team',
        component: AverageGradeDetailsComponent,
      },
    ],   },   {
    path: 'nfldraftanalysis/averagegradeswithsteal',
    component: AverageGradeWithStealComponent,   },   { path: 'nfldraftanalysis/about', component: AboutComponent },   { path: '**', component: NotFoundComponent }, ]

When the route is navigated to "http://localhost:4200/nfldraftanalysis/averagegrades?year=:year&teamname=:team", it doesn't pick up the child component but it renders the parent component view. How to avoid this behavior?

Upvotes: 0

Views: 40

Answers (1)

Rafi Henig
Rafi Henig

Reputation: 6424

As apposed to Url parameters which should be registered by RouteModule, Query parameters should not.

Upvotes: 1

Related Questions