call function for every row of *ngFor angular2

后端 未结 1 1703
遥遥无期
遥遥无期 2021-01-24 23:04

I have to display a table and call a function for every row of table and the function called once for a row.


                 


        
相关标签:
1条回答
  • 2021-01-24 23:33

    You can add a directive

    @Directive({ selector: '[invoke]'})
    class InvokeDirective {
      @Output() invoke:EventEmitter = new EventEmitter();
      ngAfterContentInit() {
        this.invoke.emit(null);
      }
    }
    

    And the use it like

    <tr *ngFor="let item of mf.data" (invoke)="myFunction(item)" >
    
    0 讨论(0)
提交回复
热议问题