我需要通过ng-style
设置从配置对象元素的背景,但我不能这样做,对于一些未知的原因,这对我来说真的很奇怪,我真的找不到理由。吴式不工作的背景
元素我想配置:
<div id="progress-l" ng-style="{ 'width': pblc.options.width, 'height': pblc.options.height, 'background': plbc.options.color }"></div>
pblc
代表控制器在这里,我使用controllerAs
选项
配置对象:
this.progressLOptions = {
color: '#F0F3F4',
width: '200px',
height: '20px',
};
最奇怪的是宽度和高度设置,在呈现html我看到这个:
<div id="progress-l" ng-style="{ 'width': pblc.options.width, 'height': pblc.options.height, 'background': plbc.options.color }" style="width: 200px; height: 20px;">
</div>
我真的不知道如何可以ng样式工作是这样的。有没有我无法找到的背景问题?
什么是'pblc.options',正如我可以看到你有'progressLOptions',你有没有搞砸范围变量名? –
@PankajParkar nope,我只是使用'controllerAs'作为指令,如果是命名,高度和宽度不会设置得太 – kemsbe