axy*_*108 18 html javascript css twitter-bootstrap angularjs
我是Angularjs的新手,当我的控制器中的值发生变化时,我正在尝试更新进度条的宽度.
我有类似的东西:
<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>
Run Code Online (Sandbox Code Playgroud)
我在我的控制器中有类似的东西:
$scope.total = 254.78;
$scope.threshold = 15000;
$scope.getPercentage = function () {
return (($scope.total * 100) / $scope.threshold).toFixed(2);
}
$scope.getTotal = function () {
return $scope.total;
}
Run Code Online (Sandbox Code Playgroud)
如何更新进度条的宽度值?
谢谢,Alberto.
Dog*_*Dog 46
ng-style指令可以解决问题.
<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>
Run Code Online (Sandbox Code Playgroud)