Y
Y
Yura072019-02-01 23:49:42
Angular
Yura07, 2019-02-01 23:49:42

How to update a component in Angular when the last part of the url changes?

Hello.
The problem is that in my application one component processes three types of pages:

  • ALL SERVICES (the "services" component is connected in html)
  • SERVICES BY CATEGORY (the same component, only displays services by category)
  • INDIVIDUAL SERVICE (a component of a separate service is connected, another is hidden)

So, on the last page, when switching from one service to another, the content does not change (the component is created once and this one exists). I tried to subscribe. Problem with the last route.
const routes: Routes = [
  {path:'', component: SiteLayoutComponent, children: [
    {path:'', component: HomePageComponent},
    {path:'home', component: HomePageComponent},
    {path:'about', component: AboutPageComponent},
    {path:'faq', component: FaqPageComponent},
    {path:'tariffs', component: TariffsPageComponent},
    {path:'bezopasnost', component: BezopasnostPageComponent},
    {path:'legal', component: LegalPageComponent},
    {path:':category', component: PayPageComponent, children: [
      {path:':service', component: PayPageComponent},
    ]}
  ]}
];

The hierarchy is like this:
  • PayPageComponent
    • OnePageComponent() is responsible for a single page. IT NEED TO BE UPDATED
    • ServicesComponent() is responsible for all services and by category


The paths are:
  • /mobile (in categories, I solved the problem by including it in the change tracking constructor, mobile can change to tariff and everything works)
  • /mobile/service1 (does not work, the category remains static, only the name of the service99 service changes)
  • /service9 (not working)

Who can advise on this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2019-02-02
@Sergamers

I didn't quite understand the description of the problem. But as an option, you can get data, which you can set in routes, and you can also get a snapshot of the route and dance from it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question