Angular 5 Material Table not getting data from service

后端 未结 2 709
生来不讨喜
生来不讨喜 2021-01-25 07:21

I am trying to simply display data from a MySQL database using Angular (5) with a Material table. The code I have compiles successfully, and a table with the column names and pa

2条回答
  •  执笔经年
    2021-01-25 07:57

    The problem is in unit-type.service.ts. It should be:

    getAllUnitTypes(): Observable {
        return this.http.get(this.unit_types_Url)
               .map(response => response.json() as UnitType[]);
    }
    

    I missed the fact that there was no data object as part of the returned JSON, so as soon as that was removed all the information was visible and correctly displayed in the table.

提交回复
热议问题