我正在尝试对输入(文本或数字)使用ng-disabled
<input ng-disabled="{{attribute.selected}}"...
我看到工作时绑定到一个复选框但我似乎无法让它在这里工作。
我试过没有{{}}但是标记只包含'attribute.selected'而不是true或false
单击md-checkbox时,我可以在chrome dev工具中看到值正在变化。 ng-disabled =“true”然后ng-disabled =“false”
使用!attribute.selected时,输入被禁用,当值变为true时不再重新启用。
完整代码段:
<md-content layout-padding layout-xs="column">
<md-checkbox md-ink-ripple="#2199FF" id="attr{{attribute.id}}" ng-model="attribute.selected">
{{attribute.name}}
</md-checkbox>
<md-content layout-padding ng-repeat="property in attribute.properties">
<md-input-container >
<label>{{property.name}}</label>
<input ng-disabled="{{attribute.selected}}" md-maxlength="{{property.maxLength}}" type="{{property.type}}" required name="{{property.name}}" ng-model="property.value">
<div ng-messages="Required">
<div ng-message="required">This is required.</div>
<div ng-message="md-maxlength">Max {{property.maxLength}} digits</div>
</div>
</md-input-container>
</md-content>
</md-content>
</div>
答案 0 :(得分:0)
更改ng-disabled =“{{attribute.selected}}”按ng-disabled =“attribute.selected”
<md-content layout-padding layout-xs="column">
<md-checkbox md-ink-ripple="#2199FF" id="attr{{attribute.id}}" ng-model="attribute.selected">
{{attribute.name}}
</md-checkbox>
<md-content layout-padding ng-repeat="property in attribute.properties">
<md-input-container >
<label>{{property.name}}</label>
<input ng-disabled="attribute.selected" md-maxlength="{{property.maxLength}}" type="{{property.type}}" required name="{{property.name}}" ng-model="property.value">
<div ng-messages="Required">
<div ng-message="required">This is required.</div>
<div ng-message="md-maxlength">Max {{property.maxLength}} digits</div>
</div>
</md-input-container>
</md-content>
</md-content>