ng-disabled="condition" not disabling the div even when the condition is true.
ng-disabled =“condition”即使条件为真也不禁用div。
<div ng-disabled="true">
// display something
</div>
2 个解决方案
#1
3
you can try
你可以试试
<fieldset ng-disabled="true">
// display something
</fieldset>
#2
2
Note: You can use
ng-show / ng-hide
directive for DIV elements to show or hide !注意:您可以使用ng-show / ng-hide指令显示或隐藏DIV元素!
Use for Form Elements
for appropriate usage of ng-disabled
directive. see below code snippet.
用于表单元素以适当使用ng-disabled指令。见下面的代码片段。
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="">
<label>Click me to toggle: <input type="checkbox" ng-model="checked"></label><br/>
<button ng-model="button" ng-disabled="checked">Button</button>
</div>
Reference: https://docs.angularjs.org/api/ng/directive/ngDisabled
What to disable: https://www.w3.org/TR/html5/disabled-elements.html
参考:https://docs.angularjs.org/api/ng/directive/ngDisabled禁用内容:https://www.w3.org/TR/html5/disabled-elements.html
Below elements can be disabled.
可以禁用以下元素。
- button
- 按键
- input
- 输入
- select
- 选择
- textarea
- textarea的
- optgroup
- OPTGROUP
- option
- 选项
- fieldset
- 字段集
#1
3
you can try
你可以试试
<fieldset ng-disabled="true">
// display something
</fieldset>
#2
2
Note: You can use
ng-show / ng-hide
directive for DIV elements to show or hide !注意:您可以使用ng-show / ng-hide指令显示或隐藏DIV元素!
Use for Form Elements
for appropriate usage of ng-disabled
directive. see below code snippet.
用于表单元素以适当使用ng-disabled指令。见下面的代码片段。
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="">
<label>Click me to toggle: <input type="checkbox" ng-model="checked"></label><br/>
<button ng-model="button" ng-disabled="checked">Button</button>
</div>
Reference: https://docs.angularjs.org/api/ng/directive/ngDisabled
What to disable: https://www.w3.org/TR/html5/disabled-elements.html
参考:https://docs.angularjs.org/api/ng/directive/ngDisabled禁用内容:https://www.w3.org/TR/html5/disabled-elements.html
Below elements can be disabled.
可以禁用以下元素。
- button
- 按键
- input
- 输入
- select
- 选择
- textarea
- textarea的
- optgroup
- OPTGROUP
- option
- 选项
- fieldset
- 字段集