【发布时间】:2019-04-24 12:34:54
【问题描述】:
我想从按钮工具提示中调用一个方法 selections(),它会做一些事情并返回一个需要在悬停工具提示时显示的字符串。我尝试在 html 上插入返回值,但没有成功
app.component.html
<button mat-raised-button
matTooltip={{selections()}}
matTooltipClass = "test"
aria-label="Button that displays a tooltip when focused or hovered
over">
Action
</button>
字符串“selected”需要从函数中返回并在悬停工具提示时显示
app.component.ts
selections() {
this.selectedelems = [];
this.selection.selected.map(id => this.tableData.data.filter((row: any) =>
{
if (row._id === id) {
this.selectedelems.push(row.name);
this.selected = this.selectedelems.join('\r\n');
}
}));
return this.selected;
}
【问题讨论】:
-
您的
selections函数实际上并没有返回值——您只是从filter函数返回 -
而不是 {{ }} 如果你这样做会更好 [matTooltip]="selections()"
-
@JBoothUA 我也试过了..仍然没有帮助
-
@user184994 太棒了!成功了
-
@use184994 如果您想将您的评论转换为答案,我将接受它作为答案。谢谢
标签: angular typescript angular-material