如何编码?
If >= 5 myClass1
else if
< 5 myClass2
else if
< 5 and <=2 myClass3
Run Code Online (Sandbox Code Playgroud)
这部分工作正常:$ index> = 5?'hidden-md col-lg-1':
需要解决这个问题:(($ index <= 2?'col-md-4 col-lg-2'):'col-md-2 col-lg-2')
ng-class="$index >= 5 ? 'hidden-md col-lg-1' : (($index <= 2 ? 'col-md-4 col-lg-2') : 'col-md-2 col-lg-2')"
Run Code Online (Sandbox Code Playgroud)
您也可以使用对象表示法:
ng-class="{
'hidden-md col-lg-1': $index >= 5,
'col-md-2 col-lg-2': $index < 5 && $index > 2,
'col-md-4 col-lg-2': $index <= 2,
}"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
474 次 |
| 最近记录: |