To disable a HTML anchor element with CSS, we can apply the pointer-events: none style. pointer-events: none will disable all click events on the anchor element. This is a great option when you only have access to class or style attributes. It can even be used to disable all the HTML links on a page.
Definition and UsageThe ng-disabled directive sets the disabled attribute of a form field (input, select, or textarea). The form field will be disabled if the expression inside the ng-disabled attribute returns true. The ng-disabled directive is necessary to be able to shift the value between true and false .
The ng-disabled Directive in AngularJS is used to enable or disable the HTML elements. If the expression inside the ng-disabled attribute returns true then the form field will be disabled or vice versa. It is usually applied on the form field (i.e, input, select, button, etc).
We can conditionally enable or disable anchor tags using ng-Show or ng-Hide directives.
There is no disabled attribute for hyperlinks. You can do this:
.disabled {
cursor: not-allowed;
}
<a ng-click="disabled()" ng-class="{disabled: addInviteesDisabled()}">Add</a>
$scope.disabled = function() {
if($scope.addInviteesDisabled) { return false;}
}
You could create a linkDisabled
css class, and apply it to your anchor:
<style>
.linkDisabled {
cursor: not-allowed;
pointer-events: none;
color: grey;
}
</style>
You can do this through CSS, no fancy directives needed. Just use ng-class to apply a class sort of like this:
ng-class:
ng-class="{disabledLink: disabledFunction()}"
css:
.disabledLink {
color: #ccc;
pointer-events:none;
}
full credit to-
https://css-tricks.com/pointer-events-current-nav/
You can't disable anchor tag using ng-disabled
.
Form control has disabled property but anchor tag has no disable property.
Check Why does angular's ng-disabled works with bootstrap's btn class?
You can user fieldset for enable disable a link.
<input type="checkbox" ng-model="vm.iagree"> I Agree
<fieldset ng-disabled="!vm.iagree">
<a class="btn btn-primary grey" href="javascript:void(0)" ng-click="vm.Submit()">Submit</a>
</fieldset>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With