From 52b8211fd0154b9d6b771a83573a161f5580d92c Mon Sep 17 00:00:00 2001 From: P. Envall Date: Fri, 19 Jul 2013 17:02:17 +0200 Subject: feat(ngRepeat): add $even and $odd props to iterator --- src/ng/directive/ngRepeat.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/ng/directive') diff --git a/src/ng/directive/ngRepeat.js b/src/ng/directive/ngRepeat.js index b5fa60dd..7da67105 100644 --- a/src/ng/directive/ngRepeat.js +++ b/src/ng/directive/ngRepeat.js @@ -17,6 +17,8 @@ * | `$first` | {@type boolean} | true if the repeated element is first in the iterator. | * | `$middle` | {@type boolean} | true if the repeated element is between the first and last in the iterator. | * | `$last` | {@type boolean} | true if the repeated element is last in the iterator. | + * | `$even` | {@type boolean} | true if the iterator position `$index` is even (otherwise false). | + * | `$odd` | {@type boolean} | true if the iterator position `$index` is odd (otherwise false). | * * Additionally, you can also provide animations via the ngAnimate attribute to animate the **enter**, * **leave** and **move** effects. @@ -354,6 +356,7 @@ var ngRepeatDirective = ['$parse', '$animator', function($parse, $animator) { childScope.$first = (index === 0); childScope.$last = (index === (arrayLength - 1)); childScope.$middle = !(childScope.$first || childScope.$last); + childScope.$odd = !(childScope.$even = index%2==0); if (!block.startNode) { linker(childScope, function(clone) { -- cgit v1.2.3