angularjs ng-style doesn't work on background

2019-09-05 04:17发布

On another thread I got the information that the background can be set dynamically by using mg-style. Unfortunately I can't get it work.

syntax like this:

ng-style="{'background-image':'url(https://www.google.com/images/srpr/logo4w.png)'}"

I have a fiddle for testing: fiddle

fiddle:

<ion-item class="item-icon-right item-avatar defaultItem" data-ng-repeat="item in items " data-ng-style="{'background-image':'url({{item.url}})'}">

The background-image of the ion-item should be set to the mg-style element.

1条回答
劳资没心,怎么记你
2楼-- · 2019-09-05 04:41

Seen elsewhere (Ionic Forums - credit to maxx0r) : don't use ng-style but style instead. That has worked for me. So your example should change as follows:

<ion-item class="item-icon-right item-avatar defaultItem" data-ng-repeat="item in items " style="background-image:url({{item.url}})">

HTH, best regards.

查看更多
登录 后发表回答