title: Styling components with inline CSS - Ionic2, AngularJS
body: <p>I am trying to append an inline CSS rule for <code>background-image</code> using a dynamic variable set inside the <code>constructor</code> like so:</p>
  
  <pre><code>&lt;div style="background-image: url('{{backgroundImage}}');"&gt;
    ...
  &lt;/div&gt;
  </code></pre>
  
  <p>then in my Component:</p>
  
  <pre><code>export class SomeComponent {
  
    backgroundImage = '';
  
    constructor(public navCtrl: NavController, public navParams: NavParams) {
      this.backgroundImage = 'https://unsplash.it/200/300' ; }
  
  }
  </code></pre>
  
  <p>However, when the element is rendered to the screen, the inline <strong>CSS rule gets omitted.</strong> </p>
  
  <p>I tried using Angular's <code>ng-style</code>, but it returns "Can't bind to 'ng-style' since it isn't a known property of 'div'".</p>
  
  <p>I also tried setting <code>styles</code> inside my <code>@Component</code> declaration as noted in <a href="https://stackoverflow.com/a/23289464/3284936">this answer</a>, but this wouldn't fly in my case, as I need the <code>backgroundImage</code> variable to be dynamic. </p>