Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/375.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
Javascript 角度2中的函数未定义错误_Javascript_Jquery_Angular - Fatal编程技术网

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、列属性){
返回“编辑”
}

我不确定你的代码是否是这样工作的。通常您有一个组件模板。

那么您的代码是错误的。请参阅文档中的这个简单示例(向下滚动至完整的组件代码):