我有一个组件,它生成一个列表,其中包含数组中某些值的名称。问题是:即使数组中有20个值,列表也不会显示任何内容。
TS:
export class ListaEventiComponent implements OnInit {
results:EventoServer[] = []
constructor( public dialogRef: MatDialogRef<ListaEventiComponent>,
@Inject(MAT_DIALOG_DATA) public data:EventoServer[] ) {
this.results = data
console.log(this.results)
}
ngOnInit(): void {
}
}HTML:
<div class="row d-flex justify-content-center">
<mat-list>
<mat-list-item *ngFor="let evento of results | keyvalue">
{{evento.descrizione}}
</mat-list-item>
</mat-list>
</div>发布于 2021-10-15 12:18:18
我在这里看到了多个问题。
keyValuePipe。由于您使用了keyValuePipe angular,所以keyValuePipe时,我们需要以evento.key或evento.value的形式访问数据。这可能是{{evento.descrizione}}未定义且屏幕上未显示任何内容的原因。所以只需删除ngFor表达式中的KeyValuePipe即可。应该能行得通。
https://stackoverflow.com/questions/69583425
复制相似问题