Tobias Punke Tobias Punke - 1 year ago 1566
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?

Answer Source

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();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download