This is the response that I receive from the api in JSON
{
"content":[
{
"id":"4354345",
"name":"asdasd",
"stuff":null
},
{
"id":"4353345",
"name":"fgdfgddd",
"stuff":null
},
{
"id":"4353425",
"name":"as11111dasd",
"stuff":null
}
],
"pageable":{
"sort":{
"sorted":false,
"unsorted":true,
"empty":true
},
"offset":0,
"pageNumber":0,
"pageSize":1000,
"paged":true,
"unpaged":false
},
"totalPages":1,
"totalElements":75,
"last":true,
"number":0,
"sort":{
"sorted":false,
"unsorted":true,
"empty":true
},
"size":1000,
"first":true,
"numberOfElements":75,
"empty":false
}
My objective is to itenerate the "Content" part of the JSON,the
"id":"4354345", "name":"asdasd", "stuff":null
in a table like this:
<tbody>
<tr *ngFor="let data of dataContent; index i">
{{data[i].id}}
{{data[i].name}}
{{data[i].stuff}}
</tr>
</tbody>
I'm doing it as follows:
ngOnInit(){
this.api.getAll((error,res) => {
this.data = res;
this.dataContent = this.data.content;
});
}
if I do a console.log of dataContent[0].id or other variables, it works, but why doesn't it show anything in the html and the console is giving errors