title: Handle 403 error for images that are set as background image in a div using Angular
body: <p>I'm setting the background image for <code>div</code>s. I'm not able to trigger the error function whenever a 403 error comes for the image urls. How can I disable the image <code>div</code> whenever an error occurs. Could anyone please help?</p>
  <p><strong>HTML</strong></p>
  <pre><code>&lt;div *ngIf=&quot;imageUrl &amp;&amp; !post.imageError&quot; 
       [ngStyle]=&quot;{ 'background-image': 'url(' + post.imageUrl + ')' }&quot;              
       (error)=&quot;handleError(post, $event)&quot;&gt;
  &lt;/div&gt;
  </code></pre>
  <p><strong>TS</strong></p>
  <pre><code>  handleError(post, event) {
      console.log('error', event);
      post.imageError = true;
    }
  </code></pre>