In my project I have menu which is inside *ngFor loop and where I have menu.Id as a parameter to load data from database
<li *ngFor="let item of menu">
<a [routerLink]="['/products', item .Id]">{{item .Name}}</a>
</li>
when I click this menu item for first time (no matter which one) it works great but after that to click another menu item it not works because ProductsComponent is already loaded and cann't take Id again (route isn't changed '/products/:id' Id is different but constructor is already loaded and component is initialized).
In ProductsComponents' constructor getting data like this
this.route.params.subscribe(params => {
this.menuId = params.menuId;
});
- How do I can load data dynamically based on route?
- and is it possible to hide menu.Id in route?