Javascript 角度2中的函数未定义错误
我有一个这样的网格Javascript 角度2中的函数未定义错误,javascript,jquery,angular,Javascript,Jquery,Angular,我有一个这样的网格 this.columns= [ { text: 'S.No', columntype: 'textbox', filtertype: 'input', datafield: 'id', width: 50, cellsalign: 'center' }, { text: 'Edit, columntype: 'textbox', datafield: 'id', width: 50, cellsrenderer =A
this.columns=
[
{
text: 'S.No', columntype: 'textbox', filtertype: 'input', datafield: 'id', width: 50, cellsalign: 'center'
},
{
text: 'Edit, columntype: 'textbox', datafield: 'id', width: 50, cellsrenderer =Action
}
]
var Action = function (row, columnfield, value, defaulthtml, columnproperties) {
return '<button onClick="done()">edit</button>'
}
my function ,
done () {
alert('hi')
}
this.columns=
[
{
文本:'S.No',列类型:'textbox',过滤器类型:'input',数据字段:'id',宽度:50,单元格标记:'center'
},
{
text:'Edit,columntype:'textbox',数据字段:'id',宽度:50,cellsrenderer=Action
}
]
var Action=函数(行、列字段、值、默认HTML、列属性){
返回“编辑”
}
我的职能,,
完成(){
警报(“嗨”)
}
错误:未定义“完成”
我真的很难解决这个问题。我使用了jqwidgets。任何人都可以提供帮助。谢谢。对于单击事件,您应该使用angular 2指令:
var Action = function (row, columnfield, value, defaulthtml, columnproperties) {
return '<button (click)="done()">edit</button>'
}
var Action=function(行、列字段、值、默认HTML、列属性){
返回“编辑”
}
我不确定你的代码是否是这样工作的。通常您有一个组件模板。那么您的代码是错误的。请参阅文档中的这个简单示例(向下滚动至完整的组件代码):