[英]How do I use html in Template directive in Angular2?
Currently I want to have a clickable anchor tag in template to display a message. 目前我想在模板中有一个可点击的锚标记来显示一条消息。 However, during run time, I keep receiving this error. 但是,在运行时,我一直收到此错误。
Uncaught ReferenceError: display is not defined 未捕获的ReferenceError:未定义显示
My code is as followed: 我的代码如下:
prepareKendoGrid(searchresults:any[]) {
console.log(this.searchresults);
this.adhocSearchKendoGrid = {
sortable: true,
columns: [{
field: "filename",
title: " ",
width: 50,
template: "#if(filetype == 'xml') {#<i style='margin-left:10px' class='fa fa-file-code-o fa-1x'></i>#} else if(filetype == 'doc') {#<i style='margin-left:10px' class='fa fa-file-word-o fa-1x'></i>#} else if(filetype == 'pdf') {#<i style='margin-left:10px' class='fa fa-file-pdf-o fa-1x'></i>#}else if(filetype == 'txt') {#<i style='margin-left:10px' class='fa fa-file-text-o fa-1x'></i>#}#"
},
{
field: "filename",
title: "File Name",
width: 200
},
{
field: "content",
title: "Content"
},
{
field: "start_time",
title: "Conversation Date",
width: 200
},
{
field: "attachments.count",
title: "Attachments",
width: 100,
template: "<a style='margin-right:10px' (click)='display()'><i class='fa fa-paperclip fa-fw'></i></a>#: attachments.count #"
}],
dataSource: searchresults
};
let cst = new CSTGridComponent();
cst.createGrid(this.adhocSearchKendoGridId,this.adhocSearchKendoGrid);
}
display() {
console.log('ok');
}
}
It should be 它应该是
(click)='display()'
See also 也可以看看
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.