for (let i = 0; i < newsValues.length; i++) {
this.newsX[newsValues[i]] = {
title: newsValues[i].title,
date: newsValues[i].published_on,
url: newsValues[i].url,
body: newsValues[i].body,
image: newsValues[i].imageurl,
tags: newsValues[i].tags
};
}
Here I get the response, and I made my own object with properties I need, everything works except the image when I pass it through *ngFor.
this is my Html part:
<nz-layout>
<nz-content>
<header>
<h1>Cool Articles</h1>
</header>
<div class="band">
<div class="item-7" *ngFor="let news of newsData">
<a href="{{news.url}}" class="card">
<div class="thumb" [style.background-image]="'url('+news.image+')'">
</div>
<article>
<h1>{{news.title}}</h1>
<span>Release Date: {{news.date | date: 'yyyy-MM-dd'}}</span>
</article>
</a>
</div>
</div>
</nz-content>
</nz-layout>
[style.background-image]="'url(https://'+news.image+')'". Else Angular try to find your image in a directory images.cryptocompare.com/news/defaultbase hreftag. if we don't put a "/" before the image, e.g.<img src="assets/images/imagen.jpg">and base href is '/' and our app is in the directory c:/myapp, look for the file inc:/myapp/assets/images/imagen.jpg. In this case is equal use/assets/.... If your base href is another (imagine a multilanguage app wherebase href="/es-ES", if we don't put the/search in c:/myapp/es-ES/assets/images/imagen.jpg