【发布时间】:2020-05-15 13:46:15
【问题描述】:
我正在遍历一个数组并每次显示一个角度分量。
<div *ngFor="let category of categories; let i=index" id="category_{{i}}">
<app-category
[inputId]="'category_'[i]"
</app-category>
</div>
类别组件是递归的,我需要发送这个 inputId 并将其用作 html id 像这样
id="{{inputId}}_{{i}}"
app-cateogry.html
<!--Some html -->
<div *ngFor="let subCategory of subCategories; let i=index" id="subCategory_{{i}}">
<app-category
[inputId]="'category_'[i]"
</app-category>
</div>
问题是我无法像上面尝试的那样发送索引。
我也尝试过插值([inputId]="'category_'{{i}}"),但这不适用于输入
我想要实现的是在子类别组件上有一个像“category_categoryIndex_subCategory_subCategoryIndex”这样的ID
【问题讨论】:
-
inputId="category_{{i}}" -
你会在this post找到答案。
标签: angular