2015-07-06 04:29:05 +00:00
|
|
|
'use strict';
|
|
|
|
|
2017-04-23 03:48:28 +00:00
|
|
|
angular.module('forms').directive('onFinishRender', function ($rootScope) {
|
2015-07-06 04:29:05 +00:00
|
|
|
return {
|
|
|
|
restrict: 'A',
|
2015-08-04 21:06:16 +00:00
|
|
|
link: function (scope, element, attrs) {
|
2016-06-05 00:48:49 +00:00
|
|
|
|
2015-08-04 21:06:16 +00:00
|
|
|
//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
|
|
|
});
|
2017-04-23 03:48:28 +00:00
|
|
|
} else if(scope.$last) {
|
2015-08-21 00:17:14 +00:00
|
|
|
scope.$evalAsync(function () {
|
2015-11-12 19:45:25 +00:00
|
|
|
$rootScope.$broadcast(broadcastMessage+' Finished');
|
2015-07-28 22:29:07 +00:00
|
|
|
});
|
2015-07-06 04:29:05 +00:00
|
|
|
}
|
|
|
|
}
|
2015-07-21 23:25:45 +00:00
|
|
|
};
|
2015-07-06 04:29:05 +00:00
|
|
|
});
|