How to get object array value from data array? Below is my code
Component
FmtNews(mediasource) {
let body = mediasource;
console.log("Test body:" +body)
this.commonService.getTopNews(body)
.subscribe((res) => {
if (res['status'].code === 102) {
// this.headerService.isLoading = false;
console.log(res['data'])
}
});
}
When I console.log(res['data']) I got example like this.
(4)[..]
0: Object (mediaSource: "News Today", pageUrl: "https://www.newstoday.com", contents:)
1:Object (mediaSource: "News Today", pageUrl: "https://www.newstoday.com", contents:)
2:Object (mediaSource: "News Today", pageUrl: "https://www.newstoday.com", contents:)
3:Object (mediaSource: "News Today", pageUrl: "https://www.newstoday.com", contents:)
My problem is.., How I want to get data in object to display in HTML page
HTML
<div class="media">
<img class="mr-3" src="..." alt="Generic placeholder image">
<div class="media-body">
<h5 class="mt-0">title here</h5>
<span>url here</span>
<div>
contents here
</div>
</div>
</div>
res.dataan array of objects? if so then you can use*ngForin your template.res.datais available for the scope only which can't be used in HTML directly!res.data is an array of objects... But how i want to make a difference let say..mediaSource: "News Today" I want to display under title.` How should I do?*ngForstructural directive because he has an array.