Skip to content

Instantly share code, notes, and snippets.

@takashi
Last active August 29, 2015 13:56
Show Gist options
  • Save takashi/8971323 to your computer and use it in GitHub Desktop.
Save takashi/8971323 to your computer and use it in GitHub Desktop.
angular repeat-end directive
'use strict';
/**
* Notify when the ng-repeat is end.
* ex
* <li ng-repeat="item in items" repeat-end></li>
* And to know repeatend from other directive,
* the other directive should use scope.$on('repeatend', function() {});
*/
angular.module('ModuleName')
.directive('repeatEnd', ['$rootScope', function ($rootScope){
return {
restrict: 'A',
link: function(scope) {
if(scope.$last) {
$rootScope.$broadcast('repeatend');
}
}
};
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment