$第一ngRepeat [英] $first in ngRepeat

查看:173
本文介绍了$第一ngRepeat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数组 $ scope.items

我想,如果该项目是的 $第一个单> ngRepeat 添加CSS类

有什么事情可以用角做什么?一般来说,我怎么可以处理布尔在AJS?

 < D​​IV NG重复=项中的项目>
   < D​​IV CLASS =''> {{item.title}}< / DIV>
< / DIV>


解决方案

这应该是

 < D​​IV NG重复=项中的项目>
   < D​​IV纳克级='{在:$第一}'> {{item.title}}< / DIV>
< / DIV>

纳克级指令<一个href=\"http://docs.angularjs.org/api/ng.directive:ngClass\">http://docs.angularjs.org/api/ng.directive:ngClass而这SO THEAD <一个href=\"http://stackoverflow.com/questions/7792652/what-is-the-best-way-to-conditionally-apply-a-class-with-angularjs\">What是有条件地适用于一类angularjs的最佳方式?

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 http://docs.angularjs.org/api/ng.directive:ngClass and this SO thead What is the best way to conditionally apply a class with angularjs?

这篇关于$第一ngRepeat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆