1
- import { AfterContentInit , ChangeDetectorRef , ContentChild , ContentChildren , EventEmitter , forwardRef , QueryList , Directive , ElementRef ,
2
- HostBinding , HostListener , Input , OnChanges , OnDestroy , Optional , Output , Renderer2 , Self } from '@angular/core' ;
3
- import { Subject } from 'rxjs' ;
4
- import { takeUntil } from 'rxjs/operators' ;
5
- import { NgControl } from '@angular/forms' ;
1
+ import { ContentChildren , forwardRef , QueryList , Directive , ElementRef , Optional , Renderer2 } from '@angular/core' ;
6
2
import { Router , RouterLink , RouterLinkWithHref } from '@angular/router' ;
7
- import { MDCTabFoundation } from '@material/tabs' ;
8
- import { MdcTabAdapter } from './mdc.tab.adapter' ;
9
3
import { AbstractMdcTabDirective } from './mdc.tab.directive' ;
10
4
import { RouterActiveDetector } from '../utility/router.active.detector' ;
11
- import { asBoolean } from '../../utils/value.utils' ;
12
5
import { MdcEventRegistry } from '../../utils/mdc.event.registry' ;
13
6
14
7
@Directive ( {
@@ -21,7 +14,8 @@ export class MdcTabRouterDirective extends AbstractMdcTabDirective {
21
14
@ContentChildren ( RouterLinkWithHref , { descendants : true } ) _linksWithHrefs : QueryList < RouterLinkWithHref > ;
22
15
private routerActive : RouterActiveDetector ;
23
16
24
- constructor ( rndr : Renderer2 , root : ElementRef , registry : MdcEventRegistry , private router : Router , private cdr : ChangeDetectorRef ) {
17
+ constructor ( rndr : Renderer2 , root : ElementRef , registry : MdcEventRegistry , private router : Router ,
18
+ @Optional ( ) private link ?: RouterLink , @Optional ( ) private linkWithHref ?: RouterLinkWithHref ) {
25
19
super ( rndr , root , registry ) ;
26
20
}
27
21
@@ -33,10 +27,16 @@ export class MdcTabRouterDirective extends AbstractMdcTabDirective {
33
27
34
28
ngAfterContentInit ( ) : void {
35
29
super . ngAfterContentInit ( ) ;
36
- this . routerActive = new RouterActiveDetector ( this , this . _links , this . _linksWithHrefs , this . router , this . cdr ) ;
30
+ this . routerActive = new RouterActiveDetector ( this , this . _links , this . _linksWithHrefs , this . router ,
31
+ this . link , this . linkWithHref ) ;
37
32
this . routerActive . init ( ) ;
38
33
}
39
34
35
+ ngOnChanges ( ) : void {
36
+ if ( this . routerActive )
37
+ this . routerActive . update ( ) ;
38
+ }
39
+
40
40
/** @docs -private */
41
41
isRouterActive ( ) {
42
42
return this . _active ;
0 commit comments