title: Angular 6 - Image loaded from http observable not updating in the view
body: <p>I am struggling to make my code work where I am using angular in-memory data simulator and trying to load it using http through observable. My issue is all the text fields updates as observable returns data but the image goes blank. It looks as if the image given at the component is fixed at the load and can't be updated later. I can see the console log and correct data is being returned but it doesn't reflect on the component.</p>
  
  <p>Can you please help me here to load this image dynamically. For now I have kept image locally under assets folder but later it will be read from real api.</p>
  
  <p><strong>banner.component.ts</strong></p>
  
  <pre><code>import { Component, OnInit } from '@angular/core';
  
  import { BannerDS } from './banner-ds';
  import { BannerService } from './banner.service';
  
  
  @Component({
    selector: 'app-banner',
    templateUrl: './banner.component.html',
    styleUrls: ['./banner.component.css']
  })
  export class BannerComponent implements OnInit {
  
    bannerLoaded = false;
    banner: BannerDS;
  
    constructor(private bannerService: BannerService) { }
  
    ngOnInit() {
      this.getBanner();
    }
  
    getBanner(): void {
      this.bannerService.getBanner()
          .subscribe(banner =&gt; {
            this.banner = banner;
            this.bannerLoaded = true;
            console.log(banner);
          });
    }
  
  }
  </code></pre>
  
  <p><strong>banner.service.ts</strong></p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { HttpClient, HttpHeaders } from '@angular/common/http';
  import { Observable, of } from 'rxjs';
  import { catchError, map, tap } from 'rxjs/operators';
  
  import { BannerDS } from './banner-ds';
  
  
  @Injectable({
    providedIn: 'root'
  })
  
  export class BannerService {
  
    private bannerUrl = 'api/banner';  // URL to web api
  
    constructor(private http: HttpClient) { }
  
    /** GET heroes from the server */
    getBanner(): Observable&lt;BannerDS&gt; {
      return this.http.get&lt;BannerDS&gt;(this.bannerUrl);
    }
  
  }
  </code></pre>
  
  <p><strong>banner-ds.ts</strong></p>
  
  <pre><code>export interface BannerDS {
      id: number;
      date: string;
      from: string;
      quote: string;
      image: string;
      likes: number;
      comments_count: number;
  }
  </code></pre>
  
  <p><strong>banner.component.html</strong></p>
  
  <pre><code>&lt;!-- start banner Area --&gt;
  &lt;section class="banner-area relative" id="home" data-parallax="scroll" attr.src="{{banner?.image}}" *ngIf="bannerLoaded"&gt;
  &lt;div class="overlay-bg overlay"&gt;&lt;/div&gt;
  &lt;div class="container"&gt;
      &lt;div class="row fullscreen"&gt;
          &lt;div class="banner-content d-flex align-items-center col-lg-12 col-md-12"&gt;
              &lt;h1&gt;
                  {{banner?.quote}}
                  &lt;!-- &amp;ldquo;The world is a book&lt;br&gt;
                  and those who do not travel read only one page.&amp;rdquo;&lt;br&gt;
                  - Augustine of Hippo --&gt;
              &lt;/h1&gt;
          &lt;/div&gt;  
          &lt;div class="head-bottom-meta d-flex justify-content-between align-items-end col-lg-12"&gt;
              &lt;div class="col-lg-6 flex-row d-flex meta-left no-padding"&gt;
                  &lt;p&gt;&lt;span class="lnr lnr-heart"&gt;&lt;/span&gt; {{banner?.likes}}&lt;/p&gt;
                  &lt;p&gt;&lt;span class="lnr lnr-bubble"&gt;&lt;/span&gt; {{banner?.comments_count}}&lt;/p&gt;
              &lt;/div&gt;
              &lt;div class="col-lg-6 flex-row d-flex meta-right no-padding justify-content-end"&gt;
                  &lt;div class="user-meta"&gt;
                      &lt;h4 class="text-white"&gt;{{banner?.from}}&lt;/h4&gt;
                      &lt;p&gt;{{banner?.date}}&lt;/p&gt;
                  &lt;/div&gt;
                  &lt;img class="img-fluid user-img" src="./assets/img/afsar.jpg" alt=""&gt;
              &lt;/div&gt;
          &lt;/div&gt;                                              
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;/section&gt;
  &lt;!-- End banner Area --&gt;    
  </code></pre>
  
  <p><strong>banner json</strong></p>
  
  <pre><code>const banner = { id: 11,
          date: '15 April, 2018 12:46 pm',
          from: 'Afsar Imam',
          quote: 'The world is a book and those who do not travel read ony one page. - Augustine of Hippo',
          image: 'src/assets/img/main-bg2.jpg',
          likes: 15,
          comments_count: 6
        };
  </code></pre>