I just googled and found lot of resources to add dynamic data into HTML file but I applied most of them but nothing helps me as of now.
I just added the below lines in the app.component.html file. I can able to see the headers on the html page but I'm not able to find the values and it shows blank and I didn't find any error message in Chrome console page.
app.component.html:
<table width="100%" class="table">
<thead>
<tr>
<th> Product Name</th>
<th> API Name </th>
<th>Message</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let binary of data">
<td>{{binary.productName}}</td>
<td>{{binary.apiName}}</td>
<td>{{binary.message}}</td>
</tr>
</tbody>
</table>
app.component.ts:
getById():void {
const url:any = "http://localhost:8081/api/products?productId=23421342221";
this.http.get(url).subscribe(data =>{
console.log(data);
});
}
The above code prints an appropriate value in console as like below:
Sample JSON Array looks like below (Dummy JSON model):
{
"dataSet":[
{
"productName": "mobile",
"apiName":"Android",
"message":"Its android mobile device and model is sony m5"
},
{
"productName": "Laptop",
"apiName":"Linux",
"message":"It's linux OS and kernel version is <XXX>"
}
]
}
Can someone help me that What I missed in my code and Why It doesn't shows up. It would be great if you help me to understand the logic so that It will be very helpful for my future reference.
Thanks in advance.
