Skip to content

Instantly share code, notes, and snippets.

@DanDiplo
Created September 24, 2014 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanDiplo/1a00dc8024d34fd15883 to your computer and use it in GitHub Desktop.
Save DanDiplo/1a00dc8024d34fd15883 to your computer and use it in GitHub Desktop.
AngularJS Directive to trigger on last item in ng-repeat
// app directive
.directive('onLastRepeat', function () {
return function (scope, element, attrs) {
if (scope.$last) setTimeout(function () {
scope.$emit('onRepeatLast', element, attrs);
}, 1);
};
})
// in controller
$scope.$on('onRepeatLast', function (scope, element, attrs) {
// do something
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment