gpt4 book ai didi

AngularJS ngRepeat : how to differentiate even/odd elements?

转载 作者:行者123 更新时间:2023-12-04 01:21:01 24 4
gpt4 key购买 nike

我是 angular 的新手,并尝试执行以下操作:

<tr data-ng-repeat="element in awesomeThings">
<div ng-if="$index %2 == 0">
<td class="even">
<a href="#">
{{element}}
</a>
</td>
</div>
<div ng-if="$index %2 != 0">
<td class="odd">
<a href="#">
{{element}}
</a>
</td>
</div>
</tr>

对于上面的代码,两个 ng-if正在通过。我哪里出错了?

最佳答案

试试 $even$odd属性。引用 documentation .

喜欢:

<tr data-ng-repeat="element in awesomeThings">
<div ng-if="$even">
<td class="even">
<a href="#">
{{element}}
</a>
</td>
</div>
<div ng-if="$odd">
<td class="odd">
<a href="#">
{{element}}
</a>
</td>
</div>
</tr>

关于AngularJS ngRepeat : how to differentiate even/odd elements?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26271591/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com