Angular2嵌套ngFor [英] Angular2 nested ngFor
本文介绍了Angular2嵌套ngFor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在 Angular2 中做到这一点:
I need to do an equivalent of this in Angular2:
<?php
foreach ($somethings as $something) {
foreach ($something->children as $child) {
echo '<tr>...</tr>';
}
}
是否可以使用 ngFor 而不在<table>
和<tr>
之间添加新元素来实现?
Can this be achieved with ngFor and not adding new elements between <table>
and <tr>
?
推荐答案
我有一个示例,该示例可能与您想要的示例类似:
I have a sample that might be similar to what you want:
<table id="spreadsheet">
<tr *ngFor="let row of visibleRows">
<td class="row-number-column">{{row.rowIndex}}</td>
<td *ngFor="let col of row.columns">
<input data-id="{{col.rowIndex}}-{{col.columnIndex}}" [value]="col.cellValue" (input)="col.cellValue = $event.target.value" (click)="model.selectColumn(col)" (keyup)="navigate($event)" />
</td>
</tr>
</table>
我用它来呈现电子表格外观的网格,如下所示: http://www.syntaxsuccess.com/angular-2-samples/#/demo/spreadsheet
I use this to render out a spreadsheet looking grid as seen here: http://www.syntaxsuccess.com/angular-2-samples/#/demo/spreadsheet
这篇关于Angular2嵌套ngFor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文