Ionic2 离子2*ngFor-从列表中读取值
我的列表如下所示: 当我这样做时,它会起作用:Ionic2 离子2*ngFor-从列表中读取值,ionic2,Ionic2,我的列表如下所示: 当我这样做时,它会起作用: <ion-item-sliding *ngFor="let draft of drafts"> <ion-item> <h2> Report identification code <strong>{{ draft.report.pk }}</strong>. </h2> </ion-item>
<ion-item-sliding *ngFor="let draft of drafts">
<ion-item>
<h2>
Report identification code <strong>{{ draft.report.pk }}</strong>.
</h2>
</ion-item>
</ion-item-sliding>
报告标识码{{draft.Report.pk}。
如何读取第1节中项目的值?例如,我如何读取“reportTimestamp”或“reportingFacility”的值
谢谢。获取此信息有两种方法:
<ion-item>
<h2>
Report identification code <strong>{{ draft.report.pk }}</strong>.
</h2>
<p>{{draft.report.sections.section1.whateverElementYouWant}}</p>
</ion-item>
要实现这一点,有两种方法:
<ion-item>
<h2>
Report identification code <strong>{{ draft.report.pk }}</strong>.
</h2>
<p>{{draft.report.sections.section1.whateverElementYouWant}}</p>
</ion-item>
我使用了第二个选项,但它只在我使用JSON.parse时起作用。yes JSON.stringify将JSON转换为字符串,JSON.parse将JSON兼容的字符串转换为JSON对象。我使用了第二个选项,但它只在我使用JSON.parse时起作用。yes JSON.stringify将JSON转换为字符串,并将JSON.parse转换为JSON兼容字符串转换为JSON对象。
getParticularElement(sectionString){
let temp = JSON.parse(sectionString);
return temp.whateverElementYouWant //return which ever element you want to display in UI
}