【发布时间】:2021-07-12 13:24:43
【问题描述】:
我正在尝试使用 *ngFor 在表格中显示学费列表,其中每个结果的每个结果都有单独的组件,但 html 没有显示它。
-
console.log()正确打印数据(学费列表): console log data - inspect 中的元素选项卡还显示生成的
tr: inspect element tab result - 但是 html 没有显示列表:empty table
代码:
父 html 文件
<div class="card">
<h5 class="p-2 py-3">Find Tuitions By ID</h5>
<table class="table table-responsive-sm">
<thead class="thead-light font-weight-bold">
<tr>
<td scope="col">Tuition Id</td>
<td scope="col">Tuition Name</td>
<td scope="col">Classes</td>
<td scope="col">City</td>
<td scope="col">Action</td>
</tr>
</thead>
<tbody class="w-100">
<tr class="" app-tution-table-list-row *ngFor="let tution of searchedTuitions" [tution]='tution'
(viewEvent)='viewEvent($event)'>
</tr>
</tbody>
</table>
</div>
子 html tution-table-list-row.html 文件
<td scope="col" class="text-danger">{{tution.tutionId}}</td>
<td scope="col">{{tution.tutionName}}</td>
<td scope="col">{{tution.listOfClasses}}</td>
<td scope="col">{{tution.teacher.city}}</td>
<td>
<div class="row">
<div class="col-6">
<button class="button btn btn-sm btn-danger my-1" routerLink="/verification-page"
[queryParams]="{id: tution.teacher.userId}">View</button>
</div>
</div>
</td>
tution-table-list-row.ts文件
@Component({
selector: 'app-tution-table-list-row',
templateUrl: './tution-table-list-row.component.html',
styleUrls: ['./tution-table-list-row.component.css']
})
export class TutionTableListRowComponent {
@Input('tution')
tution: Tution;
@Output()
viewEvent = new EventEmitter();
[...]
}
【问题讨论】:
-
你能给我看一张你的console.log输出的照片吗??
标签: angular typescript html-table angular8 ngfor