I had a similar problem. I am using angular2 rc 1.
I solved it by creating a new component(a directive didnt work for me).
import { Component, Input, Output, EventEmitter } from '@angular/core';
@Component({
selector: 'islast',
template: '<span></span>'
})
export class LastDirective {
@Input() isLast: boolean;
@Output() onLastDone: EventEmitter<boolean> = new EventEmitter<boolean>();
ngOnInit() {
if (this.isLast)
this.onLastDone.emit(true);
}
}
Then i imported in my wanted component as child component in the directives:
directives: [LastDirective],
In html:
<tr *ngFor="let sm of filteredMembers; let last = last; let i=index;" data-id="{{sm.Id}}">
<td>
<islast [isLast]="last" (onLastDone)="modalMembersDone()"></islast>
</td>
</tr>
And of course implement modalMembersDone()
原文链接: http://stackoverflow.com/questions/36482343/angular-2-fire-event-after-ngfor