As a beginner in Angular, I am currently working on populating a table using web service request and *ngFor. Although I am able to successfully display the email data, all other elements appear as [Object object].
Here is the JSON response I am receiving:
{
"data": [
{
"id": 1,
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="771d180412371f18031a161e1b5914181a">[email protected]</a>",
"password": "$2a$10$44ghfG4Ym4COxXbj9pDBuOLBXCPRRDiIM7y77G.XEh7avm2GOxlUC",
"isAdmin": 0,
"acessTypes": [
{
"id": 1,
"accessTypeName": "User",
"subAcessTypeName": "Ver&Escrever"
}
],
"tomas": [],
"consultas": [],
"profile": "NORMALUSER"
}
],
"dataArray": null,
"errors": []
}
This is the Angular code implementation:
<table class="table table-bordered">
<tr>
<th>Email</th>
<th>Access Type</th>
<th>Sub Access Type</th>
</tr>
<tr *ngFor="let user of listUser">
<td>{{user.email}}</td>
<td>{{user.acessTypes}}</td>
<td>{{user.acessTypes}}</td>
</tr>
</table>
Below 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]
});
}
)
}