我有一個按鈕:採用NG-禁用按鈕仍然被禁用,即使在條件值發生變化
<button ng-disabled="ctrl.myService.getData().someProperty ? '' : 'disabled'">
Click me!
</button>
當應用程序加載someProperty
上ctrl.myService.getData()
不存在。所以該按鈕被禁用。
但幾秒鐘後someProperty
設置爲ctrl.myService.getData()
但我的按鈕仍然被禁用..任何想法爲什麼不啓用基於新屬性的按鈕?
您必須使用布爾運算符來觸發禁用。檢查https://stackoverflow.com/questions/45349719/using-ternary-operator-in-angularjs-to-set-an-attribute-on-an-element/45349944#45349944 – Vivz
可能的重複[在angularjs中使用三元運算符在元素上設置屬性](https://stackoverflow.com/questions/45349719/using-ternary-operator-in-angularjs-to-set-an-attribute-on-an-element) – Vivz
沒有看到任何區別使用'true'或'false' – bobbyrne01