Configured routing in app.module.ts

const appRoutes: Routes =[ { path: '', component: HomeComponent}, { path: 'house/:type/:series/:address', component: CalcComponent}, { path: 'calc-custom', component: CalcCustomComponent}, { path: 'payment', component: PaymentComponent}, { path: 'order', component: OrderComponent}, { path: 'modals', component: ModalsComponent}, { path: '**', component: NotFoundComponent } ]; 

When you click the link http: // localhost: 4000 / house / panel / p-44t-ug /? STREET = Pokrovskaya% 20, the street & HOUSE = 14 redirects to the link http: // localhost: 4000 / house / panel / p-44t-ug ? STREET = Pokrovskaya% 20 & HOUSE = 14 and issues a 404 error pattern. What am I doing wrong?

  • ?STREET=... is a request parameter, not a route parameter - overthesanity

1 answer 1

You need to treat something like this http: // localhost: 4000 / house / panel / p-44t-ug / HOUSE_ADDRESS

in accordance with this rule {path: 'house /: type /: series /: address', component: CalcComponent},

You can still rewrite the rule, removed the address

{path: 'house /: type /: series', component: CalcComponent},

and after already analyze the GET parameter

  • What is Покровская%20улица%20HOUSE=14 ? so he will not get the address, the router will not be able to parse it - overthesanity
  • part of his urla for example. but you are right, now I will correct it - Sergey Konovalov
  • Unfortunately, I need to adhere to exactly the form: localhost: 4000 / house / panel / p-44t-ug / ... Since the pages of such a plan are indexed and I need to save these query parameters. Is there any possibility? - Roman Avdeev
  • supplemented the answer above - Sergey Konovalov
  • Yes, I understand, thank you very much! - Roman Avdeev