parent
be6c95ad03
commit
1a92e3d406
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {AfterContentInit, ContentChildren, Directive, ElementRef, Input, OnChanges, OnDestroy, QueryList, Renderer} from '@angular/core';
|
||||
import {AfterContentInit, ChangeDetectorRef, ContentChildren, Directive, ElementRef, Input, OnChanges, OnDestroy, QueryList, Renderer} from '@angular/core';
|
||||
import {Subscription} from 'rxjs/Subscription';
|
||||
|
||||
import {NavigationEnd, Router} from '../router';
|
||||
|
@ -103,22 +103,18 @@ export class RouterLinkActive implements OnChanges,
|
|||
get isActive(): boolean { return this.hasActiveLink(); }
|
||||
|
||||
ngAfterContentInit(): void {
|
||||
this.links.changes.subscribe(s => this.update());
|
||||
this.linksWithHrefs.changes.subscribe(s => this.update());
|
||||
this.links.changes.subscribe(_ => this.update());
|
||||
this.linksWithHrefs.changes.subscribe(_ => this.update());
|
||||
this.update();
|
||||
}
|
||||
|
||||
@Input()
|
||||
set routerLinkActive(data: string[]|string) {
|
||||
if (Array.isArray(data)) {
|
||||
this.classes = <any>data;
|
||||
} else {
|
||||
this.classes = data.split(' ');
|
||||
}
|
||||
this.classes = (Array.isArray(data) ? data : data.split(' ')).filter(c => !!c);
|
||||
}
|
||||
|
||||
ngOnChanges(changes: {}): any { this.update(); }
|
||||
ngOnDestroy(): any { this.subscription.unsubscribe(); }
|
||||
ngOnChanges(changes: {}): void { this.update(); }
|
||||
ngOnDestroy(): void { this.subscription.unsubscribe(); }
|
||||
|
||||
private update(): void {
|
||||
if (!this.links || !this.linksWithHrefs || !this.router.navigated) return;
|
||||
|
|
|
@ -262,10 +262,10 @@ export declare class RouterLinkActive implements OnChanges, OnDestroy, AfterCont
|
|||
routerLinkActiveOptions: {
|
||||
exact: boolean;
|
||||
};
|
||||
constructor(router: Router, element: ElementRef, renderer: Renderer);
|
||||
constructor(router: Router, element: ElementRef, renderer: Renderer, cdr: ChangeDetectorRef);
|
||||
ngAfterContentInit(): void;
|
||||
ngOnChanges(changes: {}): any;
|
||||
ngOnDestroy(): any;
|
||||
ngOnChanges(changes: {}): void;
|
||||
ngOnDestroy(): void;
|
||||
}
|
||||
|
||||
/** @stable */
|
||||
|
|
Loading…
Reference in New Issue