如何使用当前值增加进度条?

时间:2016-08-17 19:18:25

标签: javascript angularjs twitter-bootstrap angular-ui-bootstrap

我有一个进度条,以百分比计算当前值,并在进度条中显示正常工作,每次$scope.dynamic值获取更新时,我想增加百分比的进度条宽度。如何实现该任务?我尝试使用$ timeout但是没有做任何事情。

ctrl.js

   $scope.counter = 0;
    var maxBytes = 5000;
    $scope.max = maxBytes;
    var currentFileBytes = [];
    var currentBytesSum;
    $scope.random = function(value) {
        $scope.dynamic = 'downloaded' + ' ' +  value + ' ' + 'Bytes' + ' ' + '  '+  parseFloat((value/maxBytes) * 100).toFixed(0) + '' + '%' + 'of 1MB';
        console.log('current value-dynamic',$scope.dynamic);
        if (value > $scope.max) {
            // execute download and delete file here if max file size is same
            console.log('bytes are same stop here');
            alert("stop recording");
        }
    };
 $timeout(function () {
     if($scope.dynamic < $scope.max) {
         $scope.counter++;
         $scope.$apply();
     }
 },1000);

main.html中

<div class="col-md-11">
            <uib-progressbar type="success" class="progress-striped" max="max" animate="true" value="dynamic"><span style="font-size: large; color: #0f0f0f">{{dynamic}}</span></uib-progressbar>
        </div>

0 个答案:

没有答案