使用角度范围值设置div的样式 [英] Set style for a div using angular Scope value
本文介绍了使用角度范围值设置div的样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个水平div来显示某些活动的百分比。我有一个外部div与 width = 100%
和一个内部div。我必须根据从控制器获得的百分比值用背景颜色填充内部div,但我的问题是百分比值在 $ scope
变量百分比。
I have a horizontal div to show the percent of some activity. I have one outer div with width=100%
and one inner div. I have to fill the inner div with background color based on percentage value obtained from the controller, but my problem is that percentage value is in $scope
variable percentage.
我的代码如下:
<div class="outerDiv">
<div class="innerDiv" style="'width':{{percentage}}"></div>
{{percentage}}
是我的范围值。但上面的代码工作不正常所以我需要的是,我必须使用范围值设置div的样式。帮助
{{percentage}}
is my scope value. But the above code is not working fine so my need is that, I have to set style for div using scope value.plz help
推荐答案
您可以使用 ng-style ={'width':width}
在您的控制器中:
$scope.width = '50%';
这篇关于使用角度范围值设置div的样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文