I'm trying to route dynamically inside a lazy loaded module. But it's not working.
lazymodule-routing.ts
{
path: "city",
component: CityComponent,
children: [{ path: "/:name", component: NameComponent }]
}
component.ts
<div *ngIf="showCities">
<mat-nav-list *ngFor="let city of cities" >
<a [routerLink]="['', city.name]" mat-list-item>
{{city.name}} <img src="{{city.country_flag_url}}" />
</a>
</mat-nav-list>
</div>
I want it to navigate to the NameComponent, but it doesn't.
Thanks in advance:)
You can use either of these methods:
1.) [routerLink]="['city', city.name]"
2.) [routerLink]="['./', city.name]"
- Relative Path