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