如何获取ngfor循环总数,然后将其显示在
在上面?
<p>Total row: "I need to display the number of row here"</p>
<table class="table" >
<tr>
<th>ID</th>
<th>Name</th>
</tr>
<tr *ngFor="let l of list">
<td>{{l.id}}</td>
<td>{{l.name}}</td>
</tr>
</table>
List.length将给出要显示的总行数
<p>Total row: "I need to display the number of row here" {{list.length}}</p>
<table class="table" >
<tr>
<th>ID</th>
<th>Name</th>
</tr>
<tr *ngFor="let l of list">
<td>{{l.id}}</td>
<td>{{l.name}}</td>
</tr>
</table>
该列表是一个数组,因此可以使用长度属性。
<p>Total row: {{list.length}}</p>
<table class="table" >
<tr>
<th>ID</th>
<th>Name</th>
</tr>
<tr *ngFor="let l of list">
<td>{{l.id}}</td>
<td>{{l.name}}</td>
</tr>
</table>