Created
September 24, 2014 19:47
-
-
Save DanDiplo/1a00dc8024d34fd15883 to your computer and use it in GitHub Desktop.
AngularJS Directive to trigger on last item in ng-repeat
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 | |
.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