When parsing rss feed in xml format, I display the images that are contained in the attibute url inside the tag <enclosure> but whenever the tag enclosure is missing because the article does not have an image, I'm getting an error in the console saying:
Cannot read property 'getAttribute' of undefined
I tried to solve this problem using onError function inside src but when the tag is missing I'm still getting the error in the console and the placeholder image is not shown.
Here's my html file:
<ion-header>
  <ion-navbar color="primary">
    <ion-title text-center>
      App Name
    </ion-title>
  </ion-navbar>
</ion-header>
<ion-content>
  <ion-list>
    <ion-item *ngFor="let entry of entries" (click)="openPage(entry)" text-wrap>
      <ion-thumbnail>
        <img class="imgmg" src="{{entry.getElementsByTagName('enclosure')[0].getAttribute('url')}}" onError="this.src='assets/images/placeholder_image.png';" >
      </ion-thumbnail>
      <h2 class="title">{{entry.getElementsByTagName('title')[0].textContent}}</h2>
    </ion-item>
  </ion-list>
</ion-content>