始终禁用ng-disabled的按钮 [英] button with ng-disabled always enabled
问题描述
我正在尝试使用ng-disabled有条件地启用/禁用保存"按钮:
I'm trying to conditionally enable/disable my Save button using ng-disabled:
<button type="button" title="Save Changes" ng-click="onSaveChanges()"
ng-disabled="{{!data.modified}}">
Save
</button>
我有一个$ scope.data.modified变量,当我的数据被修改后,它会变为true.不管是对还是错,都将启用保存"按钮.元素检查显示,禁用ng的值按预期在"true"和"false"之间切换,但是该按钮始终处于启用状态.
I have a $scope.data.modified variable that changes to true when my data has been modified. Regardless whether that is true or false, the Save button is enabled. Element inspection reveals that the value of ng-disabled toggles between "true" and "false" as expect but the button is always enabled.
推荐答案
当您使用角度js属性(例如ng-show,ng-hide,ng-disabled)时,应该没有蛇符号Ex.class={{aVaribaleinControllerScope}}
when you are using a angular js attribute (like ng-show, ng-hide, ng-disabled) it should be without the snake notation Ex.ng-disabled="!data.modified"
. For other ordinary attribute like class, id you have to use it with the snake notation. Ex. class={{aVaribaleinControllerScope}}
这篇关于始终禁用ng-disabled的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!