Skip to content

Instantly share code, notes, and snippets.

@aradnom
Created March 30, 2015 17:19
Show Gist options
  • Save aradnom/6f7eb466bc40a6fcf21f to your computer and use it in GitHub Desktop.
Save aradnom/6f7eb466bc40a6fcf21f to your computer and use it in GitHub Desktop.
Simple directive for firing an event when ng-repeat is finished populating.
'use strict';
/**
* Simple directive for emitting an event when repeat is finished
*/
App.directive( 'repeatDoneEvent', function ( $window ) {
return function( scope, element, attrs ) {
if ( scope.$last ) {
// At this point, ng-repeat is done populating - but we're not finished
// yet because $compile still has to compile any tags in the repeat
// directive
scope.$evalAsync(function() {
// NOW we're done
scope.$emit( 'ngRepeatFinished', element );
});
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment