Skip to content

Commit

Permalink
feat(LinkActive): Added default class when link is active (#72)
Browse files Browse the repository at this point in the history
* feat(LinkActive): Added default class when link is active

* fix(guard): Fixed guard in lib export

Closes #71
  • Loading branch information
brandonroberts authored and MikeRyanDev committed Apr 25, 2016
1 parent 900822e commit e6a2920
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion lib/link-active.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
16 changes: 16 additions & 0 deletions spec/link-active.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, '<a [linkActive] linkTo="/page">Page</a>')
.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'
Expand Down

0 comments on commit e6a2920

Please sign in to comment.