routerlinkactive="activeStyle" is not loading the tab using tab-nav-bar and md-tab-link
When navigating to a route (tab3) from browser, the default implementation of the navbar using and rountLinkActive is loading the content properly and selecting the specified navigation link.
But When I try to do the same flow using md-tab-nav-bar and md-tab-link, the content is loaded properly but the navigation link not getting selected.
Check how to use md-tab-nav-bar in the overview
And be sure to read this issue https://github.com/angular/material2/issues/1967.
Hi @chouclee
Instead of looking into the overview document, directly went in to the tabs-demo.html page where I routerLinkActive #rla="routerLinkActive" was not mentioned in the sample. Apology from my side for note reading the overview.
After reading the issue #1967 got the workaround and now working as expected.
<a md-tab-link
*ngFor="let tabLink of navItems; let i = index"
[routerLink]="tabLink.link"
routerLinkActive #rla="routerLinkActive"
[active]="rlaSafe && rla.isActive">
{{tabLink.label}}
</a>
private rlaSafe: boolean = false;
constructor(private changeDetectorRef: ChangeDetectorRef) { }
public ngAfterViewInit() {
this.rlaSafe = true;
this.changeDetectorRef.detectChanges();
}
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.