Tobias Punke Tobias Punke - 11 months ago 995
AngularJS Question

Angular 2: Callback when ngFor has finished

In Angular 1 I have written a custom directive ("repeater-ready") to use with

to invoke a callback method when the iteration has been completed:

if ($scope.$last === true)
$timeout(() =>

Usage in markup:

<li ng-repeat="item in vm.Items track by item.Identifier"

How can I achieve a similar functionality with
in Angular 2?


You can use something like this (ngFor local variables):

<li *ngFor="#item in Items; #last = last" [ready]="last ? false : true">

Then you can Intercept input property changes with a setter

  set ready(isReady: boolean) {
    if (isReady) someCallbackMethod();