从更改引导angularjs进度条宽度 [英] Change bootstrap progress-bar width from angularjs
本文介绍了从更改引导angularjs进度条宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Angularjs新我想更新进度条的宽度时,在我的控制器变化的值。
I'm new in Angularjs and I am trying to update the width of a progress bar when a value in my controller change.
我有这样的:
<span id="percentage">$ {{getTotal()}} ({{getPercentage()}}%)</span>
<div class="progress-bar progress-bar-warning"
role="progressbar" aria-valuenow="10" aria-valuemin="0"
aria-valuemax="100" style="width: 10%">
<span class="sr-only">10% Complete (warning)</span>
</div>
和我有我的控制器是这样的:
And I have in my controller something like:
$scope.total = 254.78;
$scope.threshold = 15000;
$scope.getPercentage = function () {
return (($scope.total * 100) / $scope.threshold).toFixed(2);
}
$scope.getTotal = function () {
return $scope.total;
}
我如何更新进度条的宽度值?
How do I update the width value of the progress bar?
谢谢,
阿尔贝托。
Thanks, Alberto.
推荐答案
纳克风格的指令会做的伎俩。
ng-style directive would do the trick.
<span id="percentage">$ {{getTotal()}} ({{getPercentage()}}%)</span>
<div class="progress-bar progress-bar-warning"
role="progressbar" aria-valuenow="{{getPercentage()}}" aria-valuemin="0"
aria-valuemax="100" ng-style="{width : ( getPercentage() + '%' ) }">
<span class="sr-only">{{getPercentage()}}% Complete (warning)</span>
</div>
这篇关于从更改引导angularjs进度条宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文