简体   繁体   中英

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 . That i can use json data but when i use this way as object only than i got error. 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.

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"
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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