一旦条件满足,我正在尝试循环一组数据,我正在显示一个标签但是它在标签前面的添加空间因为我用于ngfor的div。如何在没有空格的情况下实现显示文本。下面是我正在尝试的示例
'<div *ngFor="let rows of list" >
<label *ngIf="list.name == 'test'" >Confirm </label>
<strong>{{list.name}}</strong>
<label *ngIf="rows.name != 'test' ">dont Confirm
<strong>{{list.name}}</strong>
</label>
</div>'
你可以使用ng-container
或使用CSS删除div的间距:)
<div *ngFor="let rows of list" >
<label *ngIf="list.name == 'test'" >Confirm </label>
您的示例中必定存在错误,在ngFor列表中必须是数组。数组如何具有名称属性?保存数组的变量的名称是“list”。另外,我不会像这样命名“行”,这很令人困惑,只需将其命名为“row”即可。