Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(progressbar): use internal value to represent max
Browse files Browse the repository at this point in the history
MartinNuc committed Feb 1, 2016
1 parent f5bc293 commit f6b1c3e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/progressbar/progressbar.js
Original file line number Diff line number Diff line change
@@ -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',

0 comments on commit f6b1c3e

Please sign in to comment.