我需要通過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