2017-04-12 67 views
0

定义的错误我有这样一个网格,功能不是在角2

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') 
} 

错误:完成没有定义。

我真的很难解决这个问题。我用jqwidgets。任何人都可以请help.Thanks。

回答

0

您应该使用Click事件的角2指令:

var Action = function (row, columnfield, value, defaulthtml, columnproperties) { 

    return '<button (click)="done()">edit</button>' 
} 

而且我不知道,如果你的代码是这样工作的。通常你有一个组件模板。

+0

即使不工作 – MMR

+0

然后你的代码是错误的。在文档中看到这个简单的例子(向下滚动到完整的组件代码):https://angular.io/docs/ts/latest/tutorial/toh-pt2.html – alpham8