I've got a connexion to an API media. Sometimes, some of objects are empty and i don't know how to exclude them.
html
<div class="container-fluid" style="background-color: #212529; width: 100%;">
<div class="box" >
<div class="list-group-item" id="blc" *ngFor="let media of medias">
<h6><a href={{media.url}} >{{media.title}}</a></h6>
<img class="responsive" width="600" height="400" [src]="media.urlToImage">
<p><small>{{media.description}}</small></p>
</div>
</div>
</div>
ts
export class MediaComponent implements OnInit {
public medias = [];
constructor(public mediaService: MediaService,
private route: ActivatedRoute) { }
ngOnInit(): void {
this.route.queryParams.subscribe((params: {page?: string}) => {
this.mediaService.index(params).subscribe((res: {articles}) => {
console.log(res.articles)
this.medias = res.articles;
});
});
}
}
i want something like this :
<div class="container-fluid" style="background-color: #212529; width: 100%;">
****<div class="box" *ngIf ="media.title && media.description && media.urlToImage">****
<div class="list-group-item" id="blc" *ngFor="let media of medias">
<h6><a href={{media.url}} >{{media.title}}</a></h6>
<img class="responsive" width="600" height="400" [src]="media.urlToImage">
<p><small>{{media.description}}</small></p>
</div>
</div>
</div>