<div ng-repeat="x in spaceutilization">
<input type="checkbox" name="{{x.filenumber}}" id="{{x.id}}" class = "pdffiles" value="101SP{{x.initials}}.dwg" /><label for="{{x.id}}"><button type = "button" class = "btn btn-primary btn-sm hidden-sm hidden-xs"> PDF</button></label><br />
</div>
I need to be able to add something to this snippet that disables the input checkbox based on another AngularJS input such as {{x.status}}. I tried simply doing:
我需要能够在此片段中添加一些内容,根据另一个AngularJS输入(例如{{x.status}})禁用输入复选框。我试着干脆做:
<input type="checkbox" name="{{x.filenumber}}" id="{{x.id}}" class = "pdffiles" value="101SP{{x.initials}}.dwg" {{x.status}} />
Where status:'disabled'
but that gave an output of
状态:'禁用',但输出为
{{x.status}}=""
within the input element...which I don't understand why at all. But it seemed like the simplest route.
在输入元素内......我根本不明白为什么。但它似乎是最简单的路线。
1 个解决方案
#1
10
You need to use ng-disabled="expression"
directive, on basic of expression evaluation value it add disabled attribute to that element.Also for better attribute values evaluation you could use ng-attr
directive
您需要使用ng-disabled =“expression”指令,在表达式评估值的基础上,它将禁用属性添加到该元素。另外,为了更好的属性值评估,您可以使用ng-attr指令
Markup
<input type="checkbox" ng-attr-name="{{x.filenumber}}" ng-attr-id="{{x.id}}" class ="pdffiles"
value="101SP{{x.initials}}.dwg" ng-disabled="x.status == 'disabled'"/>
If x.status
does return a bool
value then you could directly used ng-disabled="{{x.status}}"
如果x.status确实返回bool值,那么你可以直接使用ng-disabled =“{{x.status}}”
#1
10
You need to use ng-disabled="expression"
directive, on basic of expression evaluation value it add disabled attribute to that element.Also for better attribute values evaluation you could use ng-attr
directive
您需要使用ng-disabled =“expression”指令,在表达式评估值的基础上,它将禁用属性添加到该元素。另外,为了更好的属性值评估,您可以使用ng-attr指令
Markup
<input type="checkbox" ng-attr-name="{{x.filenumber}}" ng-attr-id="{{x.id}}" class ="pdffiles"
value="101SP{{x.initials}}.dwg" ng-disabled="x.status == 'disabled'"/>
If x.status
does return a bool
value then you could directly used ng-disabled="{{x.status}}"
如果x.status确实返回bool值,那么你可以直接使用ng-disabled =“{{x.status}}”