admin管理员组文章数量:1201559
I want to style my progress bar using with percentages but following ng documentation I can't seem to grasp it. It should be 20% with, but it's 100% (default).
Fiddle: /
Here is what I have tried
HTML
<div data-ng-app>
<div data-ng-controller="ProgressBarController">
<div class="progress-bar-container">
<div class="progress-bar" ng-style="{'width' : '{{ progress }}'% }">{{ progress }}</div>
</div>
</div>
</div>
JS
function ProgressBarController($scope) {
$scope.progress = 20;
}
CSS
.progress-bar-container {
width: 300px;
height: 100px;
box-sizing: border-box;
border: 1px solid black;
}
.progress-bar {
height: 100px;
background-color: green;
}
I want to style my progress bar using with percentages but following ng documentation I can't seem to grasp it. It should be 20% with, but it's 100% (default).
Fiddle: http://jsfiddle.net/u6xp8csh/
Here is what I have tried
HTML
<div data-ng-app>
<div data-ng-controller="ProgressBarController">
<div class="progress-bar-container">
<div class="progress-bar" ng-style="{'width' : '{{ progress }}'% }">{{ progress }}</div>
</div>
</div>
</div>
JS
function ProgressBarController($scope) {
$scope.progress = 20;
}
CSS
.progress-bar-container {
width: 300px;
height: 100px;
box-sizing: border-box;
border: 1px solid black;
}
.progress-bar {
height: 100px;
background-color: green;
}
Share
Improve this question
asked Dec 8, 2014 at 13:10
StanStan
26.5k55 gold badges168 silver badges247 bronze badges
4 Answers
Reset to default 11progress
field accessible without '{{'
:
ng-style="{'width' : progress + '%' }"
http://jsfiddle.net/gc343w7x/
The inside of the ng-style is stripped down Javascript, so you have a string '{{progress}}'
immediately followed by the modulus operator %
.
ng-style="{width: progress + '%'}"
will suffice.
Move the %
inside of the quotes.
ng-style="{'width' : '{{ progress }}%' }">
<p class="bar" [style.width.%]="value">
<span>Helo The World</span>
</p>
For More Detailes click here
本文标签: javascriptHow to style element widthusing ngstyleStack Overflow
版权声明:本文标题:javascript - How to style element width % using ng-style - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738574485a2100793.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论