missingsphinx missingsphinx - 1 year ago 77
AngularJS Question

Can ng-disabled disable group of child elements?

I am trying to disable a group of element using ng-disabled in its parent element. Doesn't seem to work.
Does it mean I have to using same condition in all child element to disable ?

I am not able to disable all elements by putting ng-disabled="true" with ul or li element. It works only when I put at input element. Is this how it works ? Also ng-disabled="true" doesn't work with lable or span !

<ul style="list-style:none">
<input type="radio" id="radio1" ng-model="color" value="red">
<label for="radio1" class=""><span>Red</span></label>
<input type="radio" id="radio2" ng-model="color" value="green">
<label for="radio2" class=""><span>Green</span></label>
<input type="radio" id="radio3" ng-model="color" value="blue">
<label for="radio3" class=""><span>Blue</span></label>

fiddle : http://jsfiddle.net/chiranjib_halder1/pqvz9veu/3/

Answer Source

ng-disabled is used on input elements only. here, "checked" is used to enable the button after the checkbox has been checked. here is a hypothetic example:

Click me to toggle: <input type="checkbox" ng-model="checked"><br/>
<button ng-model="button" ng-disabled="checked">Button</button>