diff --git a/lib/index.ts b/lib/index.ts index 2d63384..1ff3f81 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -34,7 +34,7 @@ export function provideRouter(routes: Routes) { } -export { Guard, createGuard } from './guard'; +export { Guard, provideGuard } from './guard'; export { LocationChange, Router } from './router'; export { Middleware, createMiddleware } from './middleware'; export { RouteParams, QueryParams } from './params'; diff --git a/lib/link-active.ts b/lib/link-active.ts index 75077cc..749529e 100644 --- a/lib/link-active.ts +++ b/lib/link-active.ts @@ -30,7 +30,7 @@ export interface LinkActiveOptions { */ @Directive({ selector: '[linkActive]' }) export class LinkActive implements AfterViewInit, OnDestroy { - @Input('linkActive') activeClass: string; + @Input('linkActive') activeClass: string = 'active'; @Input() activeOptions: LinkActiveOptions = { exact: true }; private _sub: any; diff --git a/spec/link-active.spec.ts b/spec/link-active.spec.ts index e7d6a23..2034805 100644 --- a/spec/link-active.spec.ts +++ b/spec/link-active.spec.ts @@ -59,6 +59,22 @@ describe('Link Active', () => { }); })); + it('should add a default class to the active element if not provided', injectAsync([TestComponentBuilder, Router], (tcb, router$) => { + router$.next({ + path: '/page' + }); + + return compile(tcb, 'Page') + .then((fixture) => { + fixture.detectChanges(); + let compiled = fixture.debugElement.nativeElement; + let link: Element = compiled.querySelector('a'); + + fixture.detectChanges(); + expect(link.getAttribute('class')).toEqual('active'); + }); + })); + it('should support multiple classes on the active element', injectAsync([TestComponentBuilder, Router], (tcb, router$) => { router$.next({ path: '/page'