Skip to content
This repository was archived by the owner on Mar 20, 2024. It is now read-only.

feat(RouterLink): attr router-link #98

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/directives/router_link.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {LocationStrategy} from '@angular/common';
import {Directive, HostBinding, HostListener, Input, OnChanges} from '@angular/core';
import {Directive, HostBinding, Attribute, HostListener, Input, OnChanges} from '@angular/core';

import {Router} from '../router';
import {ActivatedRoute} from '../router_state';
Expand Down Expand Up @@ -32,10 +32,11 @@ import {UrlTree} from '../url_tree';
* instead look in the current component's children for the route.
* And if the segment begins with `../`, the router will go up one level.
*/
@Directive({selector: '[routerLink]'})
@Directive({selector: '[routerLink],[router-link]'})
export class RouterLink implements OnChanges {
@Input() target: string;
private commands: any[] = [];
private routerLinkAttr: string;
@Input() queryParams: {[k: string]: any};
@Input() fragment: string;

Expand All @@ -49,7 +50,13 @@ export class RouterLink implements OnChanges {
*/
constructor(
private router: Router, private route: ActivatedRoute,
private locationStrategy: LocationStrategy) {}
private locationStrategy: LocationStrategy,
@Attribute('router-link') routerLinkAttr?: string) {
if (routerLinkAttr) {
this.commands = [routerLinkAttr];
}

}

@Input()
set routerLink(data: any[]|string) {
Expand Down