See this Plunker for the solution I managed to come up with.
It may not be elegant, but it (mostly) works!
Basically, *ngFor provides several values , such as the index, even, odd, and, fortunately, the first and last Boolean that evaluate to true for the corresponding iterations. First, you must set the values as local variables in *ngFor just like the index. Then you should get Angular to call the function from the template, which you can do as if you were binding the value to the template, but with a tertiary conditional value (which returns null for false evaluations).
<div *ngFor="let i of stuff; let l = last "> {{ i }} {{ l === true ? callOnLastIteration() : null}} </div>
I say: "(basically) it works," because it seems that if you try to bind a property inside a *ngFor -ed element other than the one you are repeating, and then changing the value of the specified property inside the function called on the last iteration, You will receive unwanted behavior and errors in the Angular change distribution system. See Plunker for more details.
source share