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) {
|
|
|
|
|
2015-08-21 00:17:14 +00:00
|
|
|
// $rootScope.$broadcast(' Started');
|
|
|
|
|
2015-08-04 21:06:16 +00:00
|
|
|
//Don't do anything if we don't have a ng-repeat on the current element
|
|
|
|
if(!element.attr('ng-repeat')){
|
|
|
|
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 () {
|
|
|
|
// console.log(Date.now());
|
|
|
|
$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 () {
|
|
|
|
// element.ready(function () {
|
2015-10-30 20:14:48 +00:00
|
|
|
console.log(broadcastMessage+'Finished');
|
2015-08-21 00:17:14 +00:00
|
|
|
// console.log(Date.now());
|
|
|
|
$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
|
|
|
});
|