I have service which return objects to component, and iterate objects inside template, some of the properties might be null and breaks the js how can I prevent this to happen ?
template:
<table id="simple-table" class="table table-striped table-bordered table-hover">
<caption>Table of artists</caption>
<thead>
<tr>
<th>id</th>
<th>name</th>
<th>image</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let artist of artists">
<td>{{artist.id}}</td>
<td>{{artist.name}}</td>
<td><img class="img-circle" style="width:100%" src="{{artist.images[0].url}}"></td>
</tr>
</tbody>
</table>
artist.images[0].url throws "annot read property 'url' of undefined" error since images is null how can I fix in single line with cascade conditions ?
console.log(this.artists)print instead ofconsole.log(data)?<div>{{artists | json}}</div>display?private cdRef:ChangeDetectorRefto constructor parameters and callthis.cdRef.detectChanges()afterthis.artists = ...;?