How can I add an active class based on the route when navigating to another route using router.navigate()
Here is the template code:
<div class="row">
<div class="col-lg-7">
<div class="row" *ngFor="let item of res " (click)="selected(item)">
{{item.name}}
<div>
<div>
</div>
<div class="col-lg-5">
<router-outlet></router-outlet>
</div>
</div>
In the corresponding TypeScript file:
import {Router , ActivatedRoute} from '@angular/router';
constructor(public router: Router, public route: ActivatedRoute) { }
routingSelected(partnerCode) {
this.router.navigate([partnerCode] , { relativeTo: this.route });
}