Reputation: 7038
Without directive, that works and display kitten
<section class="slide-show" style="background-image:url('http://placekitten.com/g/1000/175')">
hello
</section>
With ng-style, that fails :
<section class="slide-show" ng-style="{'background-image':url('http://placekitten.com/g/1000/175')}">
hello
</section>
However using ng-style with background-color works :
<section class="slide-show" ng-style="{'background-color':'blue'}">
hello
</section>
Is there a typo, or something I missed with Angular ?
Upvotes: 1
Views: 2351
Reputation: 2274
The whole value of background-image
should be inside of a string when using ng-style
.
Try this:
<section class="slide-show" ng-style="{'background-image':'url(http://placekitten.com/g/1000/175)'}">
hello
</section>
It's also worth mentioning you don't need quotes for the background-image CSS property.
**Syntax**
background-image: none
background-image: url(http://www.example.com/images/bck.png)
background-image: inherit
https://developer.mozilla.org/en-US/docs/Web/CSS/background-image
Upvotes: 4