Last active
August 29, 2015 13:56
-
-
Save takashi/8971323 to your computer and use it in GitHub Desktop.
angular repeat-end directive
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
'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