Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular ng-disabled with function

I want to use disabled-ng with dynamic value returned from a function.

I have tried several ways but it is not working.

<textarea id="{{exercise.type}}" ng-disabled={{prova}}></textarea>
......
<textarea id="{{exercise.type}}" ng-disabled=prova></textarea>
......
<textarea id="{{exercise.type}}" ng-disabled=prova()></textarea>

with this javascript function

$scope.prova=function(e){               
               return true;
       };
like image 552
jay Avatar asked Oct 02 '13 13:10

jay


People also ask

How do you write if condition in NG-disabled?

Or you can use ng-disabled="condition1 || condition2" , is depend of you logic conditional.

Which angular directive is used to disable an element?

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.

Which of the following is true about Ng-disabled directive?

Q 9 - Which of the following is true about ng-disabled directive? A - ng-disabled directive can enable a given control.

What is Ng hide directive used for?

AngularJS ng-hide Directive The ng-hide directive hides the HTML element if the expression evaluates to true. ng-hide is also a predefined CSS class in AngularJS, and sets the element's display to none .


1 Answers

Try this syntax:

ng-disabled="prova()"

Example: http://jsfiddle.net/3eqz2/2/

like image 50
Ivan Chernykh Avatar answered Sep 29 '22 05:09

Ivan Chernykh