I'm working with Angular 7 and when changing the URL parameter I do not update the content because it does not reload the constructor or the ngOnInit, all the URLs call the same components for example CategoryComponent but depending on the parameter of the URL teach some products or others.
I explain it better with code.
Component Routering.
const routes: Routes = [
{ path: '', component: HomeComponent },
{ path: ':category', component: CategoryComponent },
{ path: '**', component: Error404Component }
];
I have a menu with a dropdown-menu
<div class="dropdown-menu" aria-labelledby="dropdownMenuCategory">
<a class="dropdown-item" [routerLink]="['/robots-aspiradores']">Robots Aspiradores</a>
<a class="dropdown-item" [routerLink]="['/patinetes-electricos']">Patinetes Eléctricos</a>
<a class="dropdown-item" [routerLink]="['/cafeteras']">Cafeteras</a>
</div>
CategoryComponent builder
constructor( private _activatedRoute: ActivatedRoute, private _productService: ProductService ) {
this.url = GLOBAL.url;
this.categoryName = this._activatedRoute.snapshot.paramMap.get("category")
this.getProductsCategory(this.categoryName);
this.title = this.categoryName.replace('-', ' ').toUpperCase();
}
I want that when you click on each option in the menu, I reload the constructor or ngOnInit but it only loads the first time I enter but if I move from one category page to another it does not load anymore I have to go to the HOME and enter another category to reload.
I do not know if I explained myself well, I hope so, hello and thank you.