【发布时间】:2018-01-03 02:52:55
【问题描述】:
我正在使用 angularjs 1.6 并且需要使用特定的 css 库,如果按钮定义如下,则该库将禁用按钮:
<button disabled="">
My button
</button>
如果已定义,将启用按钮:
<button disabled="">
My button
</button>
我正在尝试根据控制器内服务中属性的最新值启用/禁用它,但即使 someProperty 已定义,该按钮始终显示为已启用......有什么想法吗?
<button {{ ctrl.myService.getData().someProperty ? '' : 'disabled=""' }}>
My button
</button>
【问题讨论】:
-
使用 ng-disabled="someProperty"
-
正如 vivz 所说
-
<button ng-disabled="ctrl.myService.getData().someProperty">My button</button>不会禁用按钮.. 即使someProperty不存在
标签: angularjs ternary-operator