AngularJS - 内联CSS样式呈现 [英] AngularJS - inline css style rendering
本文介绍了AngularJS - 内联CSS样式呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< div style =background :透明网址({{eventInfo.eventHeaderImg}})top center no-repeat;>< / div>
这是我的输出
NetworkError:404 Not Found - http://test/eventInfo.eventHeaderImg
我知道可以在控制器中更改它,但是可以用我的方法吗?
解决方案
您应该使用 ngStyle :
示例: http://plnkr.co/edit/qT8skZzTwXjrh3Ye5mr9?p=preview
< div ng-style ={background:'transparent url({{eventInfo.eventHeaderImg}})top center no-repeat'}>< / div>
Is it possible / and how / to write inline css style using angular variables?
<div style="background: transparent url({{eventInfo.eventHeaderImg}}) top center no-repeat;"></div>
This is my output
"NetworkError: 404 Not Found - http://test/eventInfo.eventHeaderImg"
So I see it didn't render this value.
I know it's possible to change this in controller, but is it doable with my approach?
解决方案
You should use ngStyle:
an example: http://plnkr.co/edit/qT8skZzTwXjrh3Ye5mr9?p=preview
<div ng-style="{ background: 'transparent url({{ eventInfo.eventHeaderImg }}) top center no-repeat' }"></div>
这篇关于AngularJS - 内联CSS样式呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文