From 5ee9d6eeb3373ff2c7b20237c001a7586655d350 Mon Sep 17 00:00:00 2001 From: JDeuker Date: Fri, 25 Sep 2015 09:26:28 +0200 Subject: [PATCH] ProgressController recalculatePercentage bugfix See: https://github.com/angular-ui/bootstrap/issues/4452 --- src/progressbar/progressbar.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/progressbar/progressbar.js b/src/progressbar/progressbar.js index 6affa08fca..4020a8c803 100644 --- a/src/progressbar/progressbar.js +++ b/src/progressbar/progressbar.js @@ -27,11 +27,10 @@ angular.module('ui.bootstrap.progressbar', []) bar.$watch('value', function(value) { bar.recalculatePercentage(); }); - + bar.recalculatePercentage = function() { - bar.percent = +(100 * bar.value / bar.max).toFixed(2); - var totalPercentage = self.bars.reduce(function(total, bar) { + bar.percent = +(100 * bar.value / bar.max).toFixed(2); return total + bar.percent; }, 0); @@ -48,6 +47,9 @@ angular.module('ui.bootstrap.progressbar', []) this.removeBar = function(bar) { this.bars.splice(this.bars.indexOf(bar), 1); + this.bars.forEach(function (bar) { + bar.recalculatePercentage(); + }); }; $scope.$watch('max', function(max) {