到目前为止,我在控制器中
原文链接:https://www.f2er.com/angularjs/144353.html$scope.currentPage = 0;
现在,在控制器中没有任何附加的代码(方法),我想在currentPage == 0时在图像上设置opacity 0.4
所以我写道:
<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 };
但它需要控制器中的附加代码