我正在使用Angular 4并尝试从我的指令中添加routerLink
属性。我添加了@HostBinding() routerLink = '/foo'
但它会导致错误。
@Directive({
selector: '[myRouterLink]'
})
export class MyRouterLinkDirective {
// this causes error: Can't bind to 'routerLink' since it isn't a known property of 'a'.
@HostBinding() routerLink = '/foo'
}
这是我的样本plunker:https://plnkr.co/edit/STpwQH?p=preview
有没有办法实现它?