Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从json文件中检索数据,并在ion列表视图中打印结果_Json_Ionic Framework_Ionic2 - Fatal编程技术网

从json文件中检索数据,并在ion列表视图中打印结果

从json文件中检索数据,并在ion列表视图中打印结果,json,ionic-framework,ionic2,Json,Ionic Framework,Ionic2,下面是我的json代码 {"samples":[ {"Date" : "Thursday 16 Mar", "Data1" : "Sample Child","Data2" : "Sample Class","Date" : "6:29 pm", "image1" : "E:\Event\www\img\img2.jpg", "text" : "Tiger Tale", "image2" : "E:\Event\www\img\img5.jpg" } {"Date" : "Tuesday 14

下面是我的json代码

{"samples":[
{"Date" : "Thursday 16 Mar", "Data1" : "Sample Child","Data2" : "Sample Class","Date" : "6:29 pm", "image1" : "E:\Event\www\img\img2.jpg", "text" : "Tiger Tale", "image2" : "E:\Event\www\img\img5.jpg" }
{"Date" : "Tuesday 14 Mar", "Data1" : "Sample Child","Data2" : "Sample Class","Date" : "12:43 pm", "image1" : "E:\Event\www\img\img6.jpg", "text" : "Tiger Tale", "image2" : "E:\Event\www\img\img4.jpg" }
{"Date" : "Friday 10 Mar","Data1" : "Sample Child","Data2" : "Sample Class","Date" : "12:03 pm", "image1" : "E:\Event\www\img\img1.jpg", "text" : "Tiger Tale", "image2" : "E:\Event\www\img\img4.jpg" }
您的typescript文件:

yourData = {
"samples":[
 {"Date" : "Thursday 16 Mar", "Data1" : "Sample Child","Data2" : "Sample       Class","Date" : "6:29 pm", "image1" : "E:\Event\www\img\img2.jpg", "text" : "Tiger Tale", "image2" : "E:\Event\www\img\img5.jpg" }
{"Date" : "Tuesday 14 Mar", "Data1" : "Sample Child","Data2" : "Sample Class","Date" : "12:43 pm", "image1" : "E:\Event\www\img\img6.jpg", "text" : "Tiger Tale", "image2" : "E:\Event\www\img\img4.jpg" }
{"Date" : "Friday 10 Mar","Data1" : "Sample Child","Data2" : "Sample Class","Date" : "12:03 pm", "image1" : "E:\Event\www\img\img1.jpg", "text" : "Tiger Tale", "image2" : "E:\Event\www\img\img4.jpg" }]
}

listData = yourData.samples;

//component template\templateURL:
<ion-list *ngFor="let item of listData">
 <ion-item>
  {{item.Data1}}
  {{item.text}}
</ion-item>
</ion-list>
yourData={
“样本”:[
{“日期”:“3月16日星期四”,“数据1”:“样本孩子”,“数据2”:“样本班”,“日期”:“下午6:29”,“图像1”:“E:\Event\www\img\img2.jpg”,“文本”:“老虎故事”,“图像2”:“E:\Event\www\img\img5.jpg”}
{“日期”:“3月14日星期二”,“数据1”:“样本孩子”,“数据2”:“样本班”,“日期”:“下午12:43”,“图像1”:“E:\Event\www\img\img6.jpg”,“文本”:“老虎故事”,“图像2”:“E:\Event\www\img\img4.jpg”}
{“日期”:“3月10日星期五”,“数据1”:“样本孩子”,“数据2”:“样本班”,“日期”:“下午12:03”,“图像1”:“E:\Event\www\img\img1.jpg”,“文本”:“老虎故事”,“图像2”:“E:\Event\www\img\img4.jpg”}]
}
listData=yourData.samples;
//组件模板\templateURL:
{{item.Data1}}
{{item.text}
您的打字脚本文件:

yourData = {
"samples":[
 {"Date" : "Thursday 16 Mar", "Data1" : "Sample Child","Data2" : "Sample       Class","Date" : "6:29 pm", "image1" : "E:\Event\www\img\img2.jpg", "text" : "Tiger Tale", "image2" : "E:\Event\www\img\img5.jpg" }
{"Date" : "Tuesday 14 Mar", "Data1" : "Sample Child","Data2" : "Sample Class","Date" : "12:43 pm", "image1" : "E:\Event\www\img\img6.jpg", "text" : "Tiger Tale", "image2" : "E:\Event\www\img\img4.jpg" }
{"Date" : "Friday 10 Mar","Data1" : "Sample Child","Data2" : "Sample Class","Date" : "12:03 pm", "image1" : "E:\Event\www\img\img1.jpg", "text" : "Tiger Tale", "image2" : "E:\Event\www\img\img4.jpg" }]
}

listData = yourData.samples;

//component template\templateURL:
<ion-list *ngFor="let item of listData">
 <ion-item>
  {{item.Data1}}
  {{item.text}}
</ion-item>
</ion-list>
yourData={
“样本”:[
{“日期”:“3月16日星期四”,“数据1”:“样本孩子”,“数据2”:“样本班”,“日期”:“下午6:29”,“图像1”:“E:\Event\www\img\img2.jpg”,“文本”:“老虎故事”,“图像2”:“E:\Event\www\img\img5.jpg”}
{“日期”:“3月14日星期二”,“数据1”:“样本孩子”,“数据2”:“样本班”,“日期”:“下午12:43”,“图像1”:“E:\Event\www\img\img6.jpg”,“文本”:“老虎故事”,“图像2”:“E:\Event\www\img\img4.jpg”}
{“日期”:“3月10日星期五”,“数据1”:“样本孩子”,“数据2”:“样本班”,“日期”:“下午12:03”,“图像1”:“E:\Event\www\img\img1.jpg”,“文本”:“老虎故事”,“图像2”:“E:\Event\www\img\img4.jpg”}]
}
listData=yourData.samples;
//组件模板\templateURL:
{{item.Data1}}
{{item.text}
检查此项

在构造函数中插入此代码

this.samples = [
 {"Date" : "Thursday 16 Mar", "Data1" : "Sample Child","Data2" : "Sample       Class","Date" : "6:29 pm", "image1" : "E:\Event\www\img\img2.jpg", "text" : "Tiger Tale", "image2" : "E:\Event\www\img\img5.jpg" }
{"Date" : "Tuesday 14 Mar", "Data1" : "Sample Child","Data2" : "Sample Class","Date" : "12:43 pm", "image1" : "E:\Event\www\img\img6.jpg", "text" : "Tiger Tale", "image2" : "E:\Event\www\img\img4.jpg" }
{"Date" : "Friday 10 Mar","Data1" : "Sample Child","Data2" : "Sample Class","Date" : "12:03 pm", "image1" : "E:\Event\www\img\img1.jpg", "text" : "Tiger Tale", "image2" : "E:\Event\www\img\img4.jpg" }]    
并在html中使用
ngFor

<ion-list>
    <ion-item *ngFor="let item of samples">
  {{item.Data1}}
  {{item.text}}
    </ion-item>
  </ion-list>

{{item.Data1}}
{{item.text}
检查此项

在构造函数中插入此代码

this.samples = [
 {"Date" : "Thursday 16 Mar", "Data1" : "Sample Child","Data2" : "Sample       Class","Date" : "6:29 pm", "image1" : "E:\Event\www\img\img2.jpg", "text" : "Tiger Tale", "image2" : "E:\Event\www\img\img5.jpg" }
{"Date" : "Tuesday 14 Mar", "Data1" : "Sample Child","Data2" : "Sample Class","Date" : "12:43 pm", "image1" : "E:\Event\www\img\img6.jpg", "text" : "Tiger Tale", "image2" : "E:\Event\www\img\img4.jpg" }
{"Date" : "Friday 10 Mar","Data1" : "Sample Child","Data2" : "Sample Class","Date" : "12:03 pm", "image1" : "E:\Event\www\img\img1.jpg", "text" : "Tiger Tale", "image2" : "E:\Event\www\img\img4.jpg" }]    
并在html中使用
ngFor

<ion-list>
    <ion-item *ngFor="let item of samples">
  {{item.Data1}}
  {{item.text}}
    </ion-item>
  </ion-list>

{{item.Data1}}
{{item.text}

假设json数据是一个变量名
jsonData
。现在定义一个数组
data:array。我对爱奥尼亚很陌生,所以我想知道如何将json文件中的数据检索到爱奥尼亚的空白应用程序中,并显示在爱奥尼亚列表视图中。在这种情况下,请参阅。在中,您可以看到他们是如何从json文件中检索数据的。因此,要访问json中的元素,我是否使用离子列表中的数据[1]。日期类似于
item.Date
data[I]。日期
。在ts
for(let item of data)console.log(item.Date)
for(let i In data)console.log(data[i].Date)
中,假设json数据为变量名
jsonData
。现在定义一个数组
data:array。我对爱奥尼亚很陌生,所以我想知道如何将json文件中的数据检索到爱奥尼亚的空白应用程序中,并显示在爱奥尼亚列表视图中。在这种情况下,请参阅。在中,您可以看到他们是如何从json文件中检索数据的。因此,要访问json中的元素,我是否使用离子列表中的数据[1]。日期类似于
item.Date
data[I]。日期
。在ts
for(让我输入数据)控制台.log(item.Date)
for(让我输入数据)控制台.log(数据[i].Date)
我对爱奥尼亚非常陌生,因此我想知道如何将json文件中的数据检索到爱奥尼亚的空白应用程序中,并显示在爱奥尼亚列表视图中查看此示例,该示例指导您如何在爱奥尼亚2应用程序中使用json数据,假设您想要使用托管api\服务:我对ionic非常陌生,因此我想知道如何将json文件中的数据检索到ionic中的空白应用程序中,并在ionic列表视图中显示查看此示例,该示例指导您如何在ionic 2应用程序中使用json数据,假设您希望使用托管的api\服务: