サーバーから角度テーブルに動的データを取得しようとしましたが、最初の行しか表示されていません
json構造をコードで添付しました
component.ts
values:any[];
this._userService.get_user_details(this._user.role_name)
.subscribe(
(data: any[]) => {
console.log('send');
console.log(data);
this.values=data;
}
)
サービス
get_user_details(role: string){
return this.httpClient.post('/dashboard/api/get_user_details',{role: role});
}
<table class="table table-striped">
<thead>
<tr>
<th>YIC Id</th>
<th>Name</th>
<th>Email</th>
<th>Status</th>
<th>Controls</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let one of values ,let i = index">
<td>{{one[i]._id}}</td>
<td>{{one[i].name}}</td>
<td>{{one[i].email}}</td>
<td>{{one[i].acc}}</td>
</tr>
</tbody>
</table>
私のjsonデータ
[ { _id: '1',
name: 'ranjith',
email: '[email protected]',
acc: 'y',
profile_id: 'CVRsNE73.jpg' },
{ _id: '2',
name: 'Vigne',
email: '[email protected]',
acc: 'y',
profile_id: 'Jf0qcrVL.jpg' } ]
私のコード
インデックスなしでオブジェクト変数に直接アクセスできます
<tr *ngFor="let one of values">
<td>{{one._id}}</td>
<td>{{one.name}}</td>
<td>{{one.email}}</td>
<td>{{one.acc}}</td>
</tr>
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加