有条件地将RouterLink或其他属性指令添加到Angular 2中的元素
发布时间:2020-12-17 08:02:15 所属栏目:安全 来源:网络整理
导读:在Angular 2中,如果我有像 button / button这样的元素如何有条件地添加像[routerLink] =“[‘SomeRoute’]这样的属性指令呢? 据我所知,没有直接的方法可以做到这一点。有一些解决方法……我使用过这样的东西: button *ngIf="condition" [routerLink]="['
在Angular 2中,如果我有像< button>< / button>这样的元素如何有条件地添加像[routerLink] =“[‘SomeRoute’]这样的属性指令呢?
据我所知,没有直接的方法可以做到这一点。有一些解决方法……我使用过这样的东西:
<button *ngIf="condition" [routerLink]="['SomeRoute']></button> <button *ngIf="!condition"></button> 这里有类似的讨论:link (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |