在Angular 2中,如果我有一个像<button></button>
这样的元素,我怎么才能有条件地向它添加一个像[routerLink]="['SomeRoute']
这样的属性指令呢?
在Angular 2中,如果我有一个像<button></button>
这样的元素,我怎么才能有条件地向它添加一个像[routerLink]="['SomeRoute']
这样的属性指令呢?
据我所知,没有直接的方法可以做到这一点.有一些变通办法.我用的是这样的东西:
<button *ngIf="condition" [routerLink]="['SomeRoute']"></button>
<button *ngIf="!condition"></button>
这里也有类似的讨论:link