【发布时间】:2019-02-13 19:03:06
【问题描述】:
我使用 Angular 6。我有以下 html
<table class="table table-sm table-bordered table-striped">
<tr>
<th></th>
<th>Name</th>
<th>Count Prices</th>
<th>Average Prices</th>
<th>Total Prices</th><th></th>
</tr>
<tr *ngFor="let item of getCategoriesShortName(); let i = index;">
<paSummaryCategoryDisplay></paSummaryCategoryDisplay>
</tr>
</table>
我想在一个组件中显示每个表的 td。 paSummaryCategoryDisplay 是
@Component({
selector: "paSummaryCategoryDisplay",
template: ` <td style="vertical-align:middle">
{{item.summaryCategory.totalPrices}}</td>
<td style="vertical-align:middle" >
{{item.summaryCategory.countPrices}}</td>
<td style="vertical-align:middle" >
{{item.summaryCategory.averagePrices}}</td>`
})
我得到了错误
Identifier 'item' is not defined. The component declaration, template variable declarations, and element references do not contain such a member
如何将项目从 html 设置到模板?
【问题讨论】:
-
您需要通过 @Input 将项目传递给组件。
-
我阅读了这篇文章,但我不明白如何将元素项从我的表格 html 传递到我的模板。我认为在 html 中我无法定义输入
标签: angular