Potato Running Potato Running - 1 year ago 79
AngularJS Question

How to prevent an a element's click event what bind by angular?

I have an a element like this

<a class='btn' ng-click="alert('clicked')"></a>

in js


I had tested use ng-disabled but dose not work.
this is my html
this is my html
this is my directive
this is my directive

I have many a element in my project so I want to write a directive like ng-disable how to write it?

Answer Source

I think this is the way to solve the problem,thank you for all of you to help me sole the problem~

.directive('a', function() {
return {
    restrict: "E",
    replace: true,
    scope: {

    link: function(scope, elem, attr) {
        if (attr['ngDisabled']) {


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download