I need to call the function after *ngFor is finished. For it i make like this:
@Directive({
selector:'[method]'
})
export class CallbackDirective implements OnDestroy{
private called:boolean = false;
@Input('method') method: Function;
@Input('clause')
set condition(value:any){
if(!value || value == false) return;
if(!this.called && this.method){
this.method();
this.called = true;
}
}
constructor(){}
}
html
<div class="media" *ngFor="let item of items; let i = index; let last = last" [method]="navigate" [clause]="last">
code in componet
id:number;
constructor(){
this.id = 0; //some value
}
navigate(){
if(this.id)
//do something
}
I have a problem - when call "navigate"'s function param "id" is undefined. How I get value "id" in navigate method?