AngularJS version 1.5+
I am facing an issue in loading my scripts every time ng-repeat is updated with the data.
The fiddle link here shows the directive which will work fine on the page load.
<div class="thing" ng-repeat="thing in things" on-finish-render>
thing {{thing}}
</div>
.directive('onFinishRender',['$timeout', '$parse', function ($timeout, $parse) {
return {
restrict: 'A',
link: function (scope, element, attr) {
scope.$watch('$last',function(newValue){
if (newValue){
$timeout(function () {
// Loading some scripts
});
}
});
}
}
}]);
But I want the scripts to load every time the ng-repeat has rendered the item on the search page (Means only updating the view using ajax calls).
As the ng-repeat is used on the search page the ajax call will be made and the data will be updated every time. As soon as data is updated and ng-repeat has finished the rendering I want to trigger some scripts.
I had gone through a lot of solutions like Calling a function when ng-repeat has finished
These all solutions work fine when the page is refreshed. If only the data is updated on the page and the ng-repeat is triggered then the directive won't trigger.
Looking for some solution that will trigger after the entire ng-repeat is loaded.
Thanks in advance
Check this fiddle here