Created
November 20, 2015 14:19
-
-
Save marlun78/2aa5dac4607d30ad145d to your computer and use it in GitHub Desktop.
A set of directives that works with ngRepeate
This file contains 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
angular.module('me.repeat', []) | |
.directive('meRepeat', repeatDirective) | |
.directive('meRepeateven', repeatEvenDirective) | |
.directive('meRepeatodd', repeatOddDirective) | |
.directive('meRepeatstart', repeatStartDirective) | |
.directive('meRepeatmiddle', repeatMiddleDirective) | |
.directive('meRepeatend', repeatEndDirective); | |
function repeatDirective() { | |
return function (scope, element, attrs) { | |
scope.$eval(attrs.meRepeat); | |
}; | |
} | |
function repeatEvenDirective() { | |
return function (scope, element, attrs) { | |
if (scope.$even) { | |
scope.$eval(attrs.meRepeateven); | |
} | |
}; | |
} | |
function repeatOddDirective() { | |
return function (scope, element, attrs) { | |
if (scope.$odd) { | |
scope.$eval(attrs.meRepeatodd); | |
} | |
}; | |
} | |
function repeatStartDirective() { | |
return function (scope, element, attrs) { | |
if (scope.$first) { | |
scope.$eval(attrs.meRepeatstart); | |
} | |
}; | |
} | |
function repeatMiddleDirective() { | |
return function (scope, element, attrs) { | |
if (scope.$middle) { | |
scope.$eval(attrs.meRepeatmiddle); | |
} | |
}; | |
} | |
function repeatEndDirective() { | |
return function (scope, element, attrs) { | |
if (scope.$last) { | |
scope.$eval(attrs.meRepeatend); | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment