这是我从服务传递到组件的响应,我应该在其中向UI显示每个值。我需要解析每个值并将其存储到变量。
[{"profileId":"000234","profileName":"kofi prfl","regionName":"NA ","fileType":"GRRCN","fileVersion":"1.01","fileFreq":"D01","fileFormat":"FIX","emptyFile":"N","cardMask":"Y","uprInd":"N","dataLevel":"01"}]
this.profileDetailsService.getProfileDetails(this.idDisplay)
.subscribe(profileResponse => {
// Should parse the profileResponse here....
this.searchResult = profileResponse;
this.spinnerService.hide();
},
error => {
this.spinnerService.hide();
this.showError();
}
);
如何分隔profileId,profileName,regionName等值?
而不是在您的代码中:
...
this.searchResult = profileResponse;
...
您可以使用:
searchResult: any[];
...
this.searchResult = profileResponse.json() || {}
...
那么您可以通过searchResult项目访问每个属性:
this.searchResult[0].profileId, etc
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句