This should be a simple problem, but I can't seem to find a solution.
(这应该是一个简单的问题,但我似乎无法找到解决方案。)
I have the following markup:
(我有以下标记:)
<div style="width:20px; height:20px; margin-top:10px; border:solid 1px black; background-color:#ff0000;"></div>
I need the background color to be bound to the scope, so I tried this:
(我需要将背景颜色绑定到范围,所以我尝试了这个:)
<div style="{width:20px; height:20px; margin-top:10px; border:solid 1px black; background-color:{{data.backgroundCol}};}"></div>
That didn't work, so I did some research and found ng-style
, but that didn't work, so I tried taking the dynamic part out and just hard-coding the style in ng-style
, like this...
(这不起作用,所以我做了一些研究并发现了ng-style
,但是没有用,所以我尝试将动态部分拿出来,只是用ng-style
硬编码ng-style
,就像这样......)
<div ng-style="{width:20px; height:20px; margin-top:10px; border:solid 1px black; background-color:#ff0000;}"></div>
and that doesn't even work.
(这甚至都不起作用。)
Am I misunderstanding how ng-style
works?(我是否误解了ng-style
工作原理?)
Is there a way of putting {{data.backgroundCol}}
into a plain style attribute and getting it to insert the value?(有没有办法将{{data.backgroundCol}}
放入普通样式属性并让它插入值?)
ask by jonhobbs translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…