angularjs ng-style: background-image isn't working

后端 未结 8 1179
一整个雨季
一整个雨季 2020-12-12 20:38

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

8条回答
  •  孤街浪徒
    2020-12-12 20:40

    IF you have data you're waiting for the server to return (item.id) and have a construct like this:

    ng-style="{'background-image':'url(https://www.myImageplusitsid/{{item.id}})'}"
    

    Make sure you add something like ng-if="item.id"

    Otherwise you'll either have two requests or one faulty.

提交回复
热议问题