Alex Art2019-10-07 23:29:11
Alex Art, 2019-10-07 23:29:11

Angular routing with a parameter. How to update a component based on a parameter?

Good day! I have this route

const appRoutes: Routes = [
  { path: 'catalog/:sectionCode', component: RazdelComponent },
  { path: 'catalog/:sectionCode/:elementCode', component: TovarComponent },

And so I go to localhost:4200/catalog/seraf/product, where there is a link in the HTML of the TovarComponent component
<a [routerLink]="['/catalog/seraf', 'tovar2']">Товар 2</a>

when you switch to which, absolutely nothing happens, except for updating the url. That is, the parameters of the component do not change. How to force Angular to reload a component when following a link if the link leads to the same component that is displayed initially?
Even in the official example , the same problem is observed(
Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Anton Shvets, 2019-10-08

Subscribe to stream route.params

Mikhail Osher, 2019-10-08

Everything is in the docks: https://angular.io/guide/router#route-parameters (Milestone 3, Heroes Feature, Route Parameters)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question