Angular 5 Material Table not getting data from service

后端 未结 2 736
生来不讨喜
生来不讨喜 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:48

    Try to use an elvis operator ? in the template to begin with. If it is just the template issue, that should get your problem solved.

    [length]="unitTypeDatabase?.data?.length"
    

    The reason is when the view is rendered there is no unitTypeDatabase defined yet as it is only initialized in the ngOnInit(). See if that fixes your issue.

提交回复
热议问题