From f6b1c3e7df24dbe29b0dfce52581244b3fb37230 Mon Sep 17 00:00:00 2001 From: Martin Nuc Date: Mon, 1 Feb 2016 14:34:12 +0100 Subject: [PATCH] fix(progressbar): use internal value to represent max --- src/progressbar/progressbar.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/progressbar/progressbar.js b/src/progressbar/progressbar.js index 8e983c6c3c..77f103b881 100644 --- a/src/progressbar/progressbar.js +++ b/src/progressbar/progressbar.js @@ -10,7 +10,7 @@ angular.module('ui.bootstrap.progressbar', []) animate = angular.isDefined($attrs.animate) ? $scope.$parent.$eval($attrs.animate) : progressConfig.animate; this.bars = []; - $scope.max = angular.isDefined($scope.max) ? $scope.max : progressConfig.max; + $scope.max = getMaxOrDefault(); this.addBar = function(bar, element, attrs) { if (!animate) { @@ -19,7 +19,7 @@ angular.module('ui.bootstrap.progressbar', []) this.bars.push(bar); - bar.max = $scope.max; + bar.max = getMaxOrDefault(); bar.title = attrs && angular.isDefined(attrs.title) ? attrs.title : 'progressbar'; bar.$watch('value', function(value) { @@ -50,12 +50,17 @@ angular.module('ui.bootstrap.progressbar', []) }); }; - $scope.$watch('max', function(max) { + //$attrs.$observe('maxParam', function(maxParam) { + $scope.$watch('maxParam', function(maxParam) { self.bars.forEach(function(bar) { - bar.max = $scope.max; + bar.max = getMaxOrDefault(); bar.recalculatePercentage(); }); }); + + function getMaxOrDefault () { + return angular.isDefined($scope.maxParam) ? $scope.maxParam : progressConfig.max; + } }]) .directive('uibProgress', function() { @@ -65,7 +70,7 @@ angular.module('ui.bootstrap.progressbar', []) controller: 'UibProgressController', require: 'uibProgress', scope: { - max: '=?' + maxParam: '=?max' }, templateUrl: 'uib/template/progressbar/progress.html' }; @@ -94,7 +99,7 @@ angular.module('ui.bootstrap.progressbar', []) controller: 'UibProgressController', scope: { value: '=', - max: '=?', + maxParam: '=?max', type: '@' }, templateUrl: 'uib/template/progressbar/progressbar.html',