简体   繁体   English

进度条值不是从零开始

[英]progress bar value not starting at zero

I have a progress bar and instead of the value starting at zero, it starts at some other value, moves back to zero and then goes forward. 我有一个进度条,而不是从零开始的值,而是从其他某个值开始,移回零然后前进。

Code for Progressbar 进度条代码

    <div class="modal-header">  
    </div>
    <div class="modal-body">
    <div>
        <progressbar class="progress-striped active" max="100" type='success' value="progress"></progressbar>
   </div>

in the open function of modal - 在模态的开放功能中-

     function open(){
     $scope.progress = 0;
     var modalInstance = $modal.open({
        animation: true,
        templateUrl: 'views/progressBar.html',
        controller: 'progressController',
        scope: $scope
    });
};

controller.js controller.js

    angular.module('app').controller('progressController', function($scope, $modalInstance) {
        $scope.$watch('length', function() {
           if ($scope.length==0 && $scope.progress!=0) {
                        $modalInstance.close();
                }
      });
 });

You're setting $scope.progress = 0 inside the open function, try setting it to 0 when the controller is loaded too. 您要在open函数中设置$ scope.progress = 0,也请在加载控制器时将其设置为0。

angular.module('app').controller('progressController', function($scope, $modalInstance) {
  $scope.progress = 0;
  $scope.$watch('length', function() {
    if ($scope.length==0 && $scope.progress!=0) {
      $modalInstance.close();
    }
  });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM