因此在数据库中,我们有jsonChanges:string []参数。杰森看起来像..
"{"field":"referringPhysician","oldValue":"Medical oncologist","newValue":"Clinical oncologist"}"
在我的情况下,我需要在角度分量表中显示oldValue和newValue。 编辑用户后,下拉菜单中的这些值会自动以old和newValue的形式保存到数据库中,但仅包含一个string []参数。我需要以某种方式从此数组中提取此值并显示它们。
1-我的桌子
<table class="listing">
<thead>
<th class="table-column-min">User Name</th>
<th class="table-column-min">Modified Date</th>
<th class="table-column-min">Entity Name</th>
<th class="table-column-min">Old Value</th>
<th class="table-column-min">New Value</th>
</thead>
<tbody>
<tr *ngFor="let at of auditTrailList | paginate: { itemsPerPage: _ITEMS_PER_PAGE, currentPage: crtPage, totalItems: totalItems }"
[attr.data-row-id]="at.userId">
<td>{{ at.userName }}</td>
<td>{{ at.timestamp ? (at.timestamp | date: CUSTOM_DATE_FORMAT ) : 'Unknown' }}</td>
<td>{{ at.entityName }}</td>
<td>TODO: old value</td>
<td>TODO: new value</td>
</tr>
</tbody>
2-我的组件
getList(patientId?: number, pageNo?: number) {
const auditTrailSubscription =
this._auditTrailService.getAuditTrailUrl(patientId, pageNo,
GridConfig.ITEMS_PER_PAGE)
.subscribe(
result => {
this.getPersonId();
this.auditTrailList = result.lstRecords;
this.totalItems = result.recordsCount;
},
err => {
this.handleError(err);
}
);
this.addSubscription("auditTrail", auditTrailSubscription);
}
答案 0 :(得分:0)
当拥有此数组时,可以将其存储在组件中的变量中并传递给html文件,例如:
this.allData={
"field":"referringPhysician",
"oldValue":"Medical oncologist",
"newValue":"Clinical oncologist"
}
,然后在您的html中显示如下:
<td>{{allData.oldValue}}</td>
<td>{{allData.newValue}}</td>