ioni3 http请求数据绑定时数组嵌套的显示问题

最近使用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:{} };


注意{},就是加上它就好了!


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值