Last active
August 29, 2015 13:56
-
-
Save IlanFrumer/9112379 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.directive('repeatStyle', function(){ | |
var classes = [ | |
'first : $first', | |
'last : $last', | |
'middle : $middle', | |
'odd : $odd', | |
'even : $even' | |
].join(', '); | |
return { | |
priority: 1001, | |
compile: function(tElm,tAttrs){ | |
if(!tAttrs.ngRepeat) return; | |
tElm.attr('ng-class', '{' + classes + '}'); | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use it like so:
<div ng-repeat="user in users" repeat-style>