我已成功将动态JSON对象加载到我的模板中,但我尝试做的是从JSON对象格式化动态结果 这是我的模板:
<tr *ngFor="let row of searchResult">
<td *ngFor=" let key of keys; let i = index;">
{{row[key]}}
</td>
</tr>
在我的脚本上,我收到了来自Web API的数据,其中包含了到JSON对象的数据
this.keys = Object.keys(this.searchResult[0]);
现在需要格式化一些JSON值,具体取决于它的内容 一个字段可以包含日期,其他字段可以包含链接,其他字段可以包含数字,...等
我应该如何动态处理这些数据格式? 如何在下面的循环中识别specifec类型
{{row[key]}}
示例JSON对象
[{"FIELD_1":"713071A","X_KYC_FULL_NAME_EN":"Atef","CASE_TYPE_CD":"CASETYPECD","PRIORITY_CD":"M","CREATE_DTTM":"2016-07-18 12:03:21.627","INVESTIGATOR_USER_ID":"user1","CASE_ID":"FATCA-2016-16095-1","CASE_CATEGORY_CD":null,"CASE_RK":16098,"X_KYC_FULL_NAME_AR":"صالح","CASE_STATUS_CD":"CBCSD"},{"FIELD_1":"713071B","X_KYC_FULL_NAME_EN":"Yasser","CASE_TYPE_CD":"CASETYPECD","PRIORITY_CD":"M","CREATE_DTTM":"2016-07-18 12:03:21.65","INVESTIGATOR_USER_ID":"user1","CASE_ID":"FATCA-2016-16095-2","CASE_CATEGORY_CD":null,"CASE_RK":16099,"X_KYC_FULL_NAME_AR":"صالح","CASE_STATUS_CD":"CBCSD"},{"FIELD_1":"713071C","X_KYC_FULL_NAME_EN":"Ahmed","CASE_TYPE_CD":"CASETYPECD","PRIORITY_CD":null,"CREATE_DTTM":"2016-07-18 12:03:21.673","INVESTIGATOR_USER_ID":"user1","CASE_DESC":null,"CASE_ID":"FATCA-2016-16095-3","CASE_CATEGORY_CD":null,"CASE_RK":16100,"X_KYC_FULL_NAME_AR":"احمد","CASE_STATUS_CD":"CBCSD"}]