0

I'm working on a grid component which has actions array that will presented as buttons

<td *ngFor="let action of actions">
        <button type='button' (click)='action.handler()'>{{action.title}}</button>
</td>

when I try this I got the following error

_v.context.$implicit.handler is not a function 
Mustafa Magdy
  • 1,230
  • 5
  • 28
  • 44

1 Answers1

1

Oooh, I got it

I shouldn't pass the handler as a string, i should pass the function reference itself

so the caller should be like this

this.actions = [{title: 'Edit', handler: this.editItem}];

instead of

this.actions = [{title: 'Edit', handler: 'editItem'}];
Mustafa Magdy
  • 1,230
  • 5
  • 28
  • 44