ioni3 http请求数据绑定时数组嵌套的显示问题
2017-09-12 15:51
225 查看
最近使用ionic3时,http请求之后,data返回来了,控制台可以console.log打印出来,但是挂不到页面上;
{
"city": "00000",
"code": "string0",
"flag": "0000",
"info": {
"contact": "13000000000",
"imgList": [
"0000000000"
],
"subject": "string",
"workTime": "9:00-21:000000"
},
"location": {
"x": 0,
"y": 0
},
"message": "0000......",
"name": "0000",
"provice": "string",
"shopImg": "assets/img/6.jpg",
"sid": "string",
"tags": [
"000000"
],
"workStatus":
"00000",
"zone": "string"
}
想要挂info里面的contact的电话号码,
http请求代码如下,都可以console.log,
ngOnInit(): void {
this.shops=this.http.get('assets/data/data.json');
this.shops
.map(res
=> res.json())
.subscribe(
data => {
console.log(data);
this.results =
data;
console.log(this.results.info);
console.log(this.results.info.contact);
})
html如下:
<p>{{ results.info.contact }}</p>
怎么样都不显示,弄了好久;
解决方法如下:
results: any = {
info:{} };
注意{},就是加上它就好了!
{
"city": "00000",
"code": "string0",
"flag": "0000",
"info": {
"contact": "13000000000",
"imgList": [
"0000000000"
],
"subject": "string",
"workTime": "9:00-21:000000"
},
"location": {
"x": 0,
"y": 0
},
"message": "0000......",
"name": "0000",
"provice": "string",
"shopImg": "assets/img/6.jpg",
"sid": "string",
"tags": [
"000000"
],
"workStatus":
"00000",
"zone": "string"
}
想要挂info里面的contact的电话号码,
http请求代码如下,都可以console.log,
ngOnInit(): void {
this.shops=this.http.get('assets/data/data.json');
this.shops
.map(res
=> res.json())
.subscribe(
data => {
console.log(data);
this.results =
data;
console.log(this.results.info);
console.log(this.results.info.contact);
})
html如下:
<p>{{ results.info.contact }}</p>
怎么样都不显示,弄了好久;
解决方法如下:
results: any = {
info:{} };
注意{},就是加上它就好了!
相关文章推荐
- ioni3 http请求数据绑定时数组嵌套的显示问题
- WPF中DataGrid控件的数据绑定与显示数组
- SenchaTouch2中list组件无法绑定存储或者绑定后仍旧无法显示数据问题解决
- 关于.net winform ComboBox数据绑定显示问题
- DevExpress中自定义CellTemplate数据绑定不显示的问题
- 有关绑定没有数据显示的问题
- 母版页中数据绑定控件不显示数据的问题
- Python中使用socket发送HTTP请求数据接收不完整问题解决方法
- Android Studio中使用volley请求数据后返回数据显示乱码的问题
- RadioButton绑定数据与显示问题,类似数据字典问题,如男女Code。
- AngularJS 用 $http.jsonp 方法跨域请求数据错误的问题
- 关于DataList嵌套DataList的问题(重点在于处理某些特殊结构与数据绑定)
- Python中使用socket发送HTTP请求数据接收不完整问题解决方法
- 用el表达式显示jquery请求servlet数据的中文乱码问题
- DataGridView绑定数据时,时间格式显示不全的问题
- 在FormView控件中嵌套数据绑定控件的问题,以及从一个对象中反射获取属性值的简单办法
- 使用HttpURLConnection采用get方式请求数据-----乱码问题
- 求助(十万火急):关于httpwebrequest发送请求绑定ip的问题.
- C#数据绑定中,时间为空时显示时间为原始日期问题
- WIN7下.Net开发遇到的又一问题:HTTP 错误 500.19 - Internal Server Error,无法访问请求的页面,因为该页的相关配置数据无效。