Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular _v、 上下文。$implicit.handler不是函数_Angular_Angular Compiler - Fatal编程技术网

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'}];