简体   繁体   English

错误:找不到类型为“ ...”的其他支持对象“ [object Object]”。 NgFor仅支持……}

[英]Error: Cannot find a differ supporting object '[object Object]' of type '…'. NgFor only supports……}

[  
   {  
      "id":1,
      "name":"Ashiz",
      "email":"ashizhamal@gmail.com",
      "message":"How are you yankee\r\n",
      "created_at":"2017-05-24 03:16:53",
      "updated_at":"2017-05-24 03:16:53"
   }
]
.map(res => res.json());

While i use json data, in above way, than it works fine . 虽然我以上述方式使用json数据,但效果很好。 That i can use json data but when i use this way as object only than i got error. 我可以使用json数据,但是当我仅将此方式用作对象时,我得到了错误。 why? 为什么? what is the differences between square bracket and without square bracket how to work with this? 方括号和不带方括号的区别是什么?

{  
   "id":1,
   "name":"Ashiz",
   "email":"ashizhamal@gmail.com",
   "message":"How are you yankee\r\n",
   "created_at":"2017-05-24 03:16:53",
   "updated_at":"2017-05-24 03:16:53"
}

When you are not using [] the you need to parse it with $.parseJSON like below. 当您不使用[] ,您需要使用$ .parseJSON进行parse ,如下所示。

jQuery.parseJSON({  
   "id":1,
   "name":"Ashiz",
   "email":"ashizhamal@gmail.com",
   "message":"How are you yankee\r\n",
   "created_at":"2017-05-24 03:16:53",
   "updated_at":"2017-05-24 03:16:53"
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM