我在控制器至今:如何用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