angularjs-ng-style

Dynamic refresh background-image with ngStyle In AngularJs

 ̄綄美尐妖づ 提交于 2019-11-28 13:40:19
When i use Angular to dynamic change div 's backgroundImage , i find there are two ways to set backgrond-image: first: <div style="background:url({{example_expression}})"></div> the second: <div ng-style="{backgroundImage: 'url({{example_expression}})'}"></div> But when i change example_expression , only the first way can dynamically change the backgroundImage. There is a example in Plunker What's wrong with ngStyle? ng-style should not contain {{}} interpolation directive, you could directly access scope variable there. Also backgroundImage should be 'background-image' Markup <div ng-style="{

Dynamic refresh background-image with ngStyle In AngularJs

爱⌒轻易说出口 提交于 2019-11-27 19:29:44
问题 When i use Angular to dynamic change div 's backgroundImage , i find there are two ways to set backgrond-image: first: <div style="background:url({{example_expression}})"></div> the second: <div ng-style="{backgroundImage: 'url({{example_expression}})'}"></div> But when i change example_expression , only the first way can dynamically change the backgroundImage. There is a example in Plunker What's wrong with ngStyle? 回答1: ng-style should not contain {{}} interpolation directive, you could