2016-08-23 37 views
0

例如,我有這樣的:如何有條件地應用基於屬性的ng-disabled?

<button ng-disabled="profile.isLoading || profile.isEmpty" ng-click="profile.saveProfile()"></button> 

我想根據我的個人資料指令,需要一個cookie的值的新屬性有條件地適用profile.isEmpty,說profile.isNewProfile。起初我以爲我可以利用三元運算符,如

<button ng-disabled="profile.isLoading || (profile.isNewProfile ? "" : "profile.isEmpty""> 

但這似乎只適用於類。有什麼想法嗎?

回答

0

使用單引號,如果newprofile可用,則設置爲空,否則設置爲isempty

<button ng-disabled="profile.isLoading || (profile.isNewProfile ? '' : profile.isEmpty)"> 
+0

感謝您的回答。看來我似乎只需要刪除引號。 – Ruth