[英]Anchor tag disabled for click
I have an anchor tag and want to make it disable for click in particular conditions. 我有一个定位标记,并希望使其在特定情况下无法点击。 I wrote a directive, but it doesn't work. 我写了一条指令,但是没有用。 Can somebody tell me where I am wrong. 有人可以告诉我我哪里错了。 When I used button, everything works, but I need anchor tag. 当我使用按钮时,一切正常,但是我需要锚标记。
In controller, I vave already set linkEnabled to false 在控制器中,我已经将linkEnabled设置为false
<a my-link="linkEnabled" title="Delete" ng-if="row.entity.status === 0" ng-click ng-really-title="Delete Item"
ng-really-no="Cancel" ng-really-yes="Delete"
ng-really-message="Are you sure you want to permanently delete {{row.entity.filename}}?"
ng-really-click="grid.appScope.deleteItem(row.entity)" class="text-danger">
<i class="fa fa-trash-alt fa-lg"></i>
</a>
Here is my directive: 这是我的指令:
'use strict'; “使用严格”;
angular.module('modio.credentialing')
.directive('myLink', function () {
return {
scope: {
enabled: '=myLink'
},
link: function (scope, element, attrs) {
element.on('click', function (event) {
if (!scope.enabled) {
event.preventDefault();
}
});
}
}
});
You don't need a custom directive for that. 您不需要为此的自定义指令。 You can disable links using css . 您可以使用css禁用链接 。
To apply conditional CSS class use ng-class
. 要应用条件CSS类,请使用ng-class
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.