Conditionally Link To Images From Twitter In Angular4
Right now I'm trying to grab the URL of images of tweets, but only if the tweet contains an image.I'm successfully able to pull tweets and pull some images, but if the tweet doesn'
Solution 1:
You can add a check to insert the div to DOM with *ngIf before assigning image to src attribute
<div *ngFor="let item of tweetsdata"><divclass="profile-pic><img src={{item.user.profile_image_url}}>
</div>
<div class="screenname">{{item.user.name}}</div><divclass="tweet-content">{{item.text}}</div><divclass="tweet-img" *ngIf="item.entities.media[0].media_url"><imgsrc="{{item.entities.media[0].media_url}}" /></div>
Post a Comment for "Conditionally Link To Images From Twitter In Angular4"