components icon indicating copy to clipboard operation
components copied to clipboard

routerlinkactive="activeStyle" is not loading the tab using tab-nav-bar and md-tab-link

Open vkishorekumar80 opened this issue 9 years ago • 3 comments

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.

ng2material-navbarlink.zip

vkishorekumar80 avatar Jan 13 '17 16:01 vkishorekumar80

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.

chouclee avatar Jan 13 '17 22:01 chouclee

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(); }

vkishorekumar80 avatar Jan 13 '17 22:01 vkishorekumar80

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.