Skip to content

Instantly share code, notes, and snippets.

@IlanFrumer
Last active August 29, 2015 13:56
Show Gist options
  • Save IlanFrumer/9112379 to your computer and use it in GitHub Desktop.
Save IlanFrumer/9112379 to your computer and use it in GitHub Desktop.
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 + '}');
}
};
});
@IlanFrumer
Copy link
Author

Use it like so:

<div ng-repeat="user in users" repeat-style>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment