How can I check if the current route matches my routerLink string?
class TestComponent implements OnInit {
@Input()
public routerCmd: string;
constructor(private router: Router) {}
ngOnInit(): void {
// Pseudo code
if (this.router.urlFromCmd(this.routerCmd) === this.router.url) {
alert('Match!');
}
}
}
<a [routerLink]="routerCmd">Link</a>
Usage
<test-component routerCmd="./tests"></test-component>
What I do not search:
<a [routerLink]="routerCmd" routerLinkActive="active">Link</a>