I'm not able to do a simple getAll in an entity. I'm using spring boot + angular 6. The spring console shows that the query is being done.
error that is appearing in the browser.
Can not find a supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
My service:
url = 'http://localhost:8080/unitys';
constructor(
public http: HttpClient
) { }
getAll() {
return this.http.get<Unity[]>(this.url);
}
My component:
export class UnityListComponent implements OnInit {
listUnitys: Unity[];
constructor(
private unityService: UnityService
) { }
ngOnInit() {
this.getAll();
}
public getAll() {
this.unityService.getAll()
.subscribe(data => {
this.listUnitys = data;
});
}
My html:
h3 class="first">Basic</h3>
<div class="ui-g">
<div class="ui-g-12">
<p-table [value]="listUnitys" [responsive]="true" #tabela>
<ng-template pTemplate="header">
<tr>
<th>ID</th>
<th>DESCRIÇÃO</th>
<th>UNIDADE</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-u.data>
<tr>
<td>{{ u.id }}</td>
<td>{{ u.name }}</td>
<td>{{ u.unity }}</td>
</tr>
</ng-template>
</p-table>
</div>