我在控制器至今:如何用ngstyle改變不透明度?
$scope.currentPage = 0;
現在,無需控制器的任何額外的代碼(方法)我想設置不透明度0.4
圖像時currentPage ==0
所以我寫了:
<div ng-controller="ctrlRead">
<div class="pagination no-margin ">
<ul>
<li ng-class="{disabled: currentPage == 0}">
<a href=""
ng-class="{disabled: currentPage == 0}">
<i class="icon-fast-backward"
ng-style="{opacity : (currentPage == 0)?'0.4':'1'}">
</i>
</a>
</li>
</ul>
</div>
</div>
但是我得到的錯誤:
Unexpected next character at columns 29-29 [?] in expression [{opacity : (currentPage == 0)?'0.4':'1'}]
難道我錯過了什麼?
謝謝
[編輯]
我可以寫ng-style="myOpacity"
,並在控制器:
$scope.myOpacity = {
'opacity': ($scope.currentPage == 0)?0.4:1
};
但它在控制器需要額外的代碼
謝謝,這一個工作:)對不起,不能投票了,必須> 15聲望 – snaggs
1對於窮人的三元!很酷。 – joshperry