tellform/base_bak/directives/on-finish-render.client.directive.js
2017-09-20 15:18:19 -07:00

27 lines
846 B
JavaScript

'use strict';
angular.module('forms').directive('onFinishRender', function ($rootScope) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
//Don't do anything if we don't have a ng-repeat on the current element
if(!element.attr('ng-repeat') && !element.attr('data-ng-repeat')){
return;
}
var broadcastMessage = attrs.onFinishRender || 'ngRepeat';
if(scope.$first && !scope.$last) {
scope.$evalAsync(function () {
$rootScope.$broadcast(broadcastMessage+' Started');
});
} else if(scope.$last) {
scope.$evalAsync(function () {
$rootScope.$broadcast(broadcastMessage+' Finished');
});
}
}
};
});