angular – 如何有条件地禁用routerLink属性?
发布时间:2020-12-17 08:03:16 所属栏目:安全 来源:网络整理
导读:在我的Angular 2应用程序中,我试图禁用routerLink而没有任何成功。我试图在click事件上处理click事件(使用event.preventDefault()和event.stopPropagation())但它不起作用。 如何禁用routerLink? 禁用指针事件 a [routerlink]="xxx" [class.disabled]="dis
在我的Angular 2应用程序中,我试图禁用routerLink而没有任何成功。我试图在click事件上处理click事件(使用event.preventDefault()和event.stopPropagation())但它不起作用。
如何禁用routerLink?
禁用指针事件
<a [routerlink]="xxx" [class.disabled]="disabled ? true : null">Link</a> a.disabled { pointer-events: none; cursor: default; } 另见Angular2,what is the correct way to disable an anchor element? 要么 <a *ngIf="isEnabled" [routerlink]="xxx">Link</a> <div *ngIf="!isEnabled">not a link</div> 或者轻松重复使用已禁用的链接模板 <ng-template #disabledLink> <div *ngIf="!isEnabled">not a link</div> </ng-template> <a *ngIf="isEnabled; else disabledLink" [routerlink]="xxx">Link</a> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |