@@ -26,11 +26,23 @@ import {ViewportRuler} from '../../core/overlay/position/viewport-ruler';
2626 encapsulation : ViewEncapsulation . None ,
2727} )
2828export class MdTabNavBar {
29+ _activeLinkChanged : boolean ;
30+ _activeLinkElement : ElementRef ;
31+
2932 @ViewChild ( MdInkBar ) _inkBar : MdInkBar ;
3033
31- /** Animates the ink bar to the position of the active link element. */
32- updateActiveLink ( element : HTMLElement ) {
33- this . _inkBar . alignToElement ( element ) ;
34+ /** Notifies the component that the active link has been changed. */
35+ updateActiveLink ( element : ElementRef ) {
36+ this . _activeLinkChanged = this . _activeLinkElement != element ;
37+ this . _activeLinkElement = element ;
38+ }
39+
40+ /** Checks if the active link has been changed and, if so, will update the ink bar. */
41+ ngAfterContentChecked ( ) : void {
42+ if ( this . _activeLinkChanged ) {
43+ this . _inkBar . alignToElement ( this . _activeLinkElement . nativeElement ) ;
44+ this . _activeLinkChanged = false ;
45+ }
3446 }
3547}
3648
@@ -39,6 +51,9 @@ export class MdTabNavBar {
3951 */
4052@Directive ( {
4153 selector : '[md-tab-link], [mat-tab-link]' ,
54+ host : {
55+ '[class.mat-tab-link]' : 'true' ,
56+ }
4257} )
4358export class MdTabLink {
4459 private _isActive : boolean = false ;
@@ -49,11 +64,11 @@ export class MdTabLink {
4964 set active ( value : boolean ) {
5065 this . _isActive = value ;
5166 if ( value ) {
52- this . _mdTabNavBar . updateActiveLink ( this . _element . nativeElement ) ;
67+ this . _mdTabNavBar . updateActiveLink ( this . _elementRef ) ;
5368 }
5469 }
5570
56- constructor ( private _mdTabNavBar : MdTabNavBar , private _element : ElementRef ) { }
71+ constructor ( private _mdTabNavBar : MdTabNavBar , private _elementRef : ElementRef ) { }
5772}
5873
5974/**
0 commit comments