gpt4 book ai didi

javascript - 如何在 Angular2 的模板指令中使用 html?

转载 作者:行者123 更新时间:2023-11-30 11:48:19 26 4
gpt4 key购买 nike

目前我想在模板中有一个可点击的 anchor 标记来显示消息。但是,在运行时,我不断收到此错误。

未捕获的 ReferenceError:未定义显示

我的代码如下:

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

最佳答案

应该是

(click)='display()'

另见

关于javascript - 如何在 Angular2 的模板指令中使用 html?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40213320/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com