I've read this question about how to determine the active route, but still it's not clear to me how to determine an active route with paramaters?
Right now I'm doing it like this:
<a [routerLink]="['/Profile/Feed', {username: username}]"
[ngClass]="{active: getLinkStyle('/profile/john_doe/feed')}">
Feed for {{username}}
</a>
And inside my component:
getLinkStyle(path:string):boolean {
console.log(this._location.path()); // logs: '/profile/john_doe/feed'
return this._location.path() === path;
}
And this will work because I'm passing the username as a string. Is there any way to do this with passing the correct parameter??
username
is from the RouteParams. But how can I pass this from my HTML to my component? @CyberAleks[ngClass]="{active: getLinkStyle('/profile/{{username}}/feed')}"
, but of course that won't work..