Angular.js idiom to disable a button when textarea is empty

I want the button to be disabled if the text is not present in the text box. Here is what I tried:

<textarea ng-model="shipment_ids"></textarea>
<button ng-click="do_something" ng-disabled="shipment_ids.length"></button>

However, the button is turned on no matter what.

+4
source share
1 answer

I think you want the opposite of what your code says. Sort of:

<textarea ng-model="shipment_ids"></textarea>
<button ng-click="do_something" ng-disabled="!shipment_ids">Click me</button>

An example in JSFiddle is here .

+17
source

Source: https://habr.com/ru/post/1547656/


All Articles