ngRepeat 中的 $first [英] $first in ngRepeat
本文介绍了ngRepeat 中的 $first的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个数组 $scope.items
.
我想如果该项目是 ngRepeat$first 之一> 添加css类in
.
是否可以用 angular 来完成?通常我如何处理 Ajs 中的布尔值?
<div class='' >{{item.title}}
解决方案
应该是
<div ng-class='{in:$first}' >{{item.title}}
查看 http://中的 ng-class
指令docs.angularjs.org/api/ng.directive:ngClass 和在这个线程 有条件地应用类的最佳方法是什么?
I have an array $scope.items
.
I want if the item is the $first
one of the ngRepeat to add the css class in
.
Is it something that can be done with angular? Generally how can I handle the booleans in Ajs?
<div ng-repeat="item in items">
<div class='' > {{item.title}}</div>
</div>
解决方案
It should be
<div ng-repeat="item in items">
<div ng-class='{in:$first}' > {{item.title}}</div>
</div>
Look at ng-class
directive in http://docs.angularjs.org/api/ng.directive:ngClass and in this thread What is the best way to conditionally apply a class?
这篇关于ngRepeat 中的 $first的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文