Error trying to diff '[object Object]' in Angular

前端 未结 4 925
情书的邮戳
情书的邮戳 2020-11-27 20:28

Looks like something wrong with freight variable in HTML:

Error in app/freightList.component.html:13:8 Error trying to diff \'[object Object]\'

4条回答
  •  旧巷少年郎
    2020-11-27 21:07

    I ran into this issue when I changed the WebApi I was calling to return a Task instead of the previous IEnumerable. Check the response isn't wrapped in an object. I had to change my extractData method to:

    private extractData(res: Response) {
       let body = res.json();
       return body.result || body || { };
    }
    

    提交回复
    热议问题