1 回答
TA贡献1725条经验 获得超7个赞
我在对应的.ts文件中定义了一个数组,如下:
checkboxes: CheckboxStructure[] = []
CheckboxStructure定义如下:
export interface CheckboxStructure
{
id: number
value: boolean
}
我写入let i = index并*ngFor附加了checkboxes数组的特定字段,[ngModel]如下所示:[ngModel] = "checkboxes[i].value"
<div *ngIf = "blogs.length > 0">
<ul>
<li *ngFor = "let blog of blogs; let i = index;" >
<a *ngIf = "blog.show === true" routerLink = "/editor/{{blog.id}}">
{{blog.title}}
creationDate: {{blog.creationDate}}
modificationDate: {{blog.modificationDate}}
</a>
<a *ngIf = "blog.show === true">
<input type = "checkbox"
[ngModel] = "checkboxes[i].value">
</a>
</li>
</ul>
</div>
- 1 回答
- 0 关注
- 84 浏览
添加回答
举报