I\'m trying to apply a background image to a div by using the angular ng-style
( I tried a custom directive before with the same behaviour ), but it doesn\'t se
If we have a dynamic value that needs to go in a css background or background-image attribute, it can be just a bit more tricky to specify.
Let’s say we have a getImage() function in our controller. This function returns a string formatted similar to this: url(icons/pen.png). If we do, the ngStyle declaration is specified the exact same way as before:
ng-style="{ 'background-image': getImage() }"
Make sure to put quotes around the background-image key name. Remember, this must be formatted as a valid Javascript object key.