我想通過for回圈在表格中顯示鍵值對,tr標簽。我想在一行中顯示3-4個配對。
在這里添加了我的代碼--https://stackblitz.com/edit/angular-ivy-hrqira?file=src/app/app.component.ts
我想在這一行中分別顯示4個值。用這個鏈接更新了我的問題。
<table>
<div *ngFor="let table of uiFields | keyvalue"/span>>
<tr>< td><label> {{table. key}}</label><label>/span>{{table. value}}</table></td>
</tr>/span>
</div>/span>
</table>
我得到的是一個在另一個下面的值,我想在一行中顯示3-4對。uiFields是我的地圖,包含不同的值。
uj5u.com熱心網友回復:
<table>
<tr>< td *ngFor="let table of uiFields | keyvalue"/span>> <label>{{table. key}}</label><label>/span>{{table. value}}</table></td>
</tr>/span>
</table>
uj5u.com熱心網友回復:
我已經嘗試了另一種方法,以檢查這是否對你有用
codeSolution:https://stackblitz.com/edit/angular-ivy-12fmx9?file=src/app/app.component.tsHTML
<table>
<div>/span>
<tr *ngFor="let items of uiFields">/span>
<td *ngFor="let table of items"/span>>
<label>{{ table.key }}</label>
{{ table.value }}}
</td>{table.value }}。
</tr>/span>
</div>/span>
</table>
ts
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']。
})
出口類AppComponent {
uiFields = [
[
{ key: 1, value: 'Rishab' },
{ key: 2, value: 'Ram' },
{ key: 3, value: 'Ramu' },
],
[
{ key: 1, value: 'Rishab' },
{ key: 2, value: 'Ram' }, { key: 2, value: 'Ram' },
{ key: 3, value: 'Ramu' },
],
[
{ key: 1, value: 'Rishab' },
{ key: 2, value: 'Ram' }, { key: 2, value: 'Ram' },
{ key: 3, value: 'Ramu' },
],
];
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/321901.html
標籤:
上一篇:如何停止影像的回應?
