Reputation: 7542
I have inputs which are disabled depending on whether a certain object has a length greater than zero.
<input ng-disabled="(entities[1].itemAttrs.length > 0)?true:false" type="text" class="form-control dropdown-toggle" data-toggle="dropdown" data-ng-disabled="formReadOnly" data-ng-model="item[item.fields[51].name]" data-ng-keyup="comboBoxTherOptions(2, 327, item[item.fields[51].name], 'searchTherOptions')" />
Here:
ng-disabled="(entities[1].itemAttrs.length > 0)?true:false"
I want to add it to my div's which, have a lot of directives that have been built over the years by people.
<div ng-disabled="(entities[1].itemAttrs.length > 0)?true:false" data-strat-form-control data-field-display-id="1" data-vmformreadonly="formReadOnly" data-show-tool-tip="showTEoolTip(item.fields[5].htmlName)" data-strat-model="item" data-field="item.fields[5]"></div>
However, it has no effect, unlike the input fields.
How can I disable these divs under the same circumstances as my inputs?
Upvotes: 1
Views: 119
Reputation: 41
Please check my code it will work as acepted
enter code here
var xx = angular.module('ap', []).controller('c', function ($scope) {
$scope.a = 0;
});
0)?true:false" type="text" class="form-control dropdown-toggle" ng-model="a" />
enter code here
Upvotes: 1
Reputation: 847
ng-disabled
simply add/remove a disabled attribute to your dom element. But, this attribute is ready for all : w3scool description.
The alternative way consists of using ng-class
and look through the world wide web on how-to make my div disabled (without any angularjs context) => sample
Upvotes: 0