fauverism
fauverism

Reputation: 1992

What elements can ng-disabled be applied to?

I thought I could apply ng-disabled to an <a> element. It's looking like I can't. It works on the <button> element. Does anyone know what elements I can apply ng-disabled to?

Upvotes: 4

Views: 375

Answers (2)

scniro
scniro

Reputation: 16979

Per usage in the ngDisabled docs

<INPUT
  ng-disabled="expression">
...
</INPUT>

An <input /> element will be eligible for this directive. This includes semantic elements such as <button> <select> and <textarea> as well. For a list of all elements this directive can be applied to, see the other form control elements.

Upvotes: 1

Pankaj Parkar
Pankaj Parkar

Reputation: 136134

You could not disable anchor tag. ng-disabled or disabled attribute only work on the button/inputs element, If you want to disable anchor tag then you should have call ng-click function on it & then on basis of it either redirect or don't do anything.

Markup

<a href="" ng-click="redirect(isValid, url)"> Anchor Button </a>

Code

$scope.redirect = function(isValid, url){
    if(isValid)
      $window.open(url, "_blank")
}

Upvotes: 3

Related Questions