Angular _v、 上下文。$implicit.handler不是函数
我正在开发一个网格组件,该组件的动作数组将显示为按钮Angular _v、 上下文。$implicit.handler不是函数,angular,angular-compiler,Angular,Angular Compiler,我正在开发一个网格组件,该组件的动作数组将显示为按钮 <td *ngFor="let action of actions"> <button type='button' (click)='action.handler()'>{{action.title}}</button> </td> 哦,我明白了 我不应该将处理程序作为字符串传递,我应该传递函数引用本身 所以打电话的人应该是这样的 this.actions = [{title:
<td *ngFor="let action of actions">
<button type='button' (click)='action.handler()'>{{action.title}}</button>
</td>
哦,我明白了
我不应该将处理程序作为字符串传递,我应该传递函数引用本身
所以打电话的人应该是这样的
this.actions = [{title: 'Edit', handler: this.editItem}];
而不是
this.actions = [{title: 'Edit', handler: 'editItem'}];
this.actions = [{title: 'Edit', handler: 'editItem'}];