tellform/public/modules/forms/directives/on-finish-render.client.directive.js

28 lines
917 B
JavaScript
Raw Normal View History

2015-07-06 04:29:05 +00:00
'use strict';
angular.module('forms').directive('onFinishRender', function ($rootScope, $timeout) {
return {
restrict: 'A',
2015-08-04 21:06:16 +00:00
link: function (scope, element, attrs) {
//Don't do anything if we don't have a ng-repeat on the current element
2015-11-06 17:41:55 +00:00
if(!element.attr('ng-repeat') && !element.attr('data-ng-repeat')){
2015-08-04 21:06:16 +00:00
return;
}
var broadcastMessage = attrs.onFinishRender || 'ngRepeat';
2015-10-30 18:40:02 +00:00
if(scope.$first && !scope.$last) {
2015-08-21 00:17:14 +00:00
scope.$evalAsync(function () {
$rootScope.$broadcast(broadcastMessage+' Started');
2015-07-28 22:29:07 +00:00
});
2015-08-04 21:06:16 +00:00
}else if(scope.$last) {
2015-08-21 00:17:14 +00:00
scope.$evalAsync(function () {
// console.log(broadcastMessage+'Finished');
$rootScope.$broadcast(broadcastMessage+' Finished');
2015-07-28 22:29:07 +00:00
});
2015-07-06 04:29:05 +00:00
}
}
};
2015-07-06 04:29:05 +00:00
});