我想将无序列表分成偶数和奇数循环,每列使用ng-repeat从1,2,3和4开始。这样做的好方法是什么?我不认为ng-class-even或ng-class-odd足以满足我想要完成的任务,但它可能起到一定的作用。
我已经知道如何使用AngularJS操作css3列,通过循环偶数和奇数来得到这个:
1 2 3 4
5 6 7 8
9 10 11 12
答案 0 :(得分:2)
<ol ng-init="names=['John', 'Mary', 'Cate', 'Suz']">
<li ng-repeat="name in names">
<span ng-class-odd="'odd'" ng-class-even="'even'">
{{name}}
</span>
</li>
</ol>
css
.odd {
color: red;
}
.even {
color: blue;
}
会给你这个:
答案 1 :(得分:0)
答案 2 :(得分:0)
<li ng-repeat="person in people" ng-class="{even: !$even, odd: !$odd}">
{{person.name}} lives in {{person.city}}
</li>
$scope.people = [
{name: "Ari", city: "San Francisco"},
{name: "Erik", city: "Seattle"}
];