I'm trying to apply a background image to a div by using the angular ng-style
and it works fine as long as the URL does not contain spaces.
ng-style="{'background-image': 'url(' + parentIMGLink + ')'}"
When there is space in URL like parentIMGLink = servername.images/there is name.png
it does not work. On the other hand:
img ng-src={{parentIMGLink }}
Works fine. For sure I can manage so that names on the server wont contain spaces but is there any possibility to make ng-style work?
Just like in css you have to wrap your the image url in quotes:
.rule{ background-image: url('/some/image url.png') }
You have to do the same here:
<div ng-style="{'background-image': 'url(\'{{imageUrl}}\')'}">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With