2
我想製作一個從0開始的進度條,並在一定時間內增加到最大值。當它達到最大值時,它會遞減並重復該過程。這是我的嘗試。AngularJS:如何製作波動的進度條?
HTML:
<progressbar class="progress-striped active"
max="max"
value="value"
type="success">
</progressbar>
JS:
app.controller('progressBar', function($scope,$timeout){
$scope.max = 100;
$scope.min = 0;
$scope.value = 0;
var increment = 5;
var target = $scope.max;
$scope.increment = function() {
$scope.value += increment;
};
$scope.decrement = function() {
$scope.value -= increment;
};
$timeout(function() {
while ($scope.value <= target) {
$scope.increment();
if($scope.value === target) {
target = $scope.min;
};
};
while ($scope.value >= target) {
$scope.decrement();
if($scope.value === target) {
target = $scope.max;
};
};
}, 1000);
});
也許你應該描述你在嘗試時遇到的問題。 –
我們不打算從頭創建一個應用程序來測試您的問題。描述你的情況和問題 – dpaul1994