I am new in Angular and I am doing a web service request to populate a table. I am using the *ngFor to populate my table. I receive my email correctly but the other elements in tree show as [Object object]
This is my JSON response:
{
"data": [
{
"id": 1,
"email": "[email protected]",
"password": "$2a$10$44ghfG4Ym4COxXbj9pDBuOLBXCPRRDiIM7y77G.XEh7avm2GOxlUC",
"isAdmin": 0,
"acessTypes": [
{
"id": 1,
"accessTypeName": "User",
"subAcessTypeName": "Ver&Escrever"
}
],
"tomas": [],
"consultas": [],
"profile": "NORMALUSER"
}
],
"dataArray": null,
"errors": []
}
This is my Angular Code´
<table class="table table-bordered">
<tr>
<th>Email</th>
<th>Tipo de acesso</th>
<th>SubTipo de acesso</th>
</tr>
<tr *ngFor="let user of listUser">
<td>{{user.email}}</td>
<td>{{user.acessTypes}}</td>
<td>{{user.acessTypes}}</td>
</tr>
</table>
This is my User component
findAll(){
this.userService.findAll().subscribe((responseApi: ResponseApi)=>{
this.listUser = responseApi['data'];
}, err => {
this.showMessage({
type: 'error',
text: err['error']['error'][0]
});
}
)
}
jsonpipe, that should show you full data<td>{{user.acessTypes | json}}</td>. But you definitely need another loop over there to access individual object properties<td>{{ user.acessTypes | json }}</td>