I want to call some jQuery function targeting div with table. That table is populated with ng-repeat
.
When I call it on
$(document).r
Maybe a bit simpler approach with ngInit
and Lodash's debounce method without the need of custom directive:
Controller:
$scope.items = [1, 2, 3, 4];
$scope.refresh = _.debounce(function() {
// Debounce has timeout and prevents multiple calls, so this will be called
// once the iteration finishes
console.log('we are done');
}, 0);
Template:
- {{item}}
There is even simpler pure AngularJS solution using ternary operator:
Template:
- {{item}}
Be aware that ngInit uses pre-link compilation phase - i.e. the expression is invoked before child directives are processed. This means that still an asynchronous processing might be required.