我正在为球队显示球场上的数据。我有正确的数据,但显示为[object,Object]。我如何在字段键中JSON.stringify?
public config = {
columns: [
{ field: 'name', label: 'Name' }, //I get the name just fine
{ field: 'age', label: 'age' }, // I get the age just fine
{ field: 'teams', label: 'Teams' }, // I get all the teams but
// [object, Object] is shown
],
}
模板
<tr *ngFor="let item of items ">
<td *ngFor="let column of config.columns">
<span *ngIf="!column.click && !column.link">
{{item[column.field] | json}}
</span>
<span *ngIf="column.link">
<a [routerLink]="[item.id, column.link]">
{{item[column.field] | json}}
</a>
</span>
</td>
</tr>
我如何在此处访问角色值。我使用'teams'字段获取此数据,但我需要专门访问角色。
[ { "programId": "feef40bb-c4a3-4185-9e89-162349acd9aad", "userId": "bab.admin", "role": "regionalManager", "id": "59408f47fd44df38a89db6e5", "created": "2017-06-14T01:20:07.273Z", "modified": "2017-06-14T01:20:07.273Z" }, { "programId": "fe2fa0bb-c3a3-4185-9e89-16779acd9aad", "userId": "bab.admin", "role": "salesManager", "id": "59408f47fd44df38a89db6e6", "created": "2017-06-14T01:20:07.275Z", "modified": "2017-06-14T01:20:07.275Z" }, ]