Angular.js idiom for disabling button when textarea is blank

angularjs, javascript, validation

Solution

I think you want the opposite of what your code states. Something like:

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

Example on JSFiddle here.

Problem

I want a button to be disabled unless text is present in a textarea. Here is what I have tried: ``` <textarea ng-model="shipment_ids"></textarea> <button ng-click="do_something" ng-disabled="shipment_ids.length"></button> ``` However, the button is enabled no matter what.

Original source