。HTML文件:它给出错误:未定义标识符"mg"。但是{{mgr[0].value}}可以使用
<button type="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="bottom" data-html="true"
title="<table class='popuptable'>
<thead>
<tr >
<th>Current Value</th>
</tr>
</thead>
<tbody>
<tr *ngFor='let mg of mgr'>
<td>{{mg.value}}
</tr>
</tbody>
</table>">
Tooltip on bottom
</button>
.ts文件:我正试图在.HTML文件中使用*ngFor循环此mgr
mgr: any[]=[{
value:'Work 1'
},
{
value:'Work 2'
}
];
您可以在<ng-template #tipContent></ng-template>
标记中为表编写html代码。
然后将模板的引用添加到[title]=";tipContent">按钮的属性。
注意:不要忘记将[]放在标题周围。
你可以参考这篇文章。https://www.freakyjolly.com/angular-ng-bootstrap-tooltip-tutorial/