diff --git a/src/progressbar/progressbar.js b/src/progressbar/progressbar.js index 9a6a6355d7..f2ee42ec84 100644 --- a/src/progressbar/progressbar.js +++ b/src/progressbar/progressbar.js @@ -10,7 +10,21 @@ angular.module('ui.bootstrap.progressbar', []) animate = angular.isDefined($attrs.animate) ? $scope.$parent.$eval($attrs.animate) : progressConfig.animate; this.bars = []; - $scope.max = angular.isDefined($attrs.max) ? $scope.$parent.$eval($attrs.max) : progressConfig.max; + + this.updateBar = function(bar) { + bar.percent = +(100 * bar.value / $scope.max).toFixed(2); + }; + + if (angular.isDefined($attrs.max)) { + $scope.$parent.$watch($attrs.max, function (new_value) { + $scope.max = new_value; + for (i=0; i{{value}} %')($rootScope); + element = $compile('{{value}} %')($rootScope); $rootScope.$digest(); })); @@ -65,6 +66,19 @@ describe('progressbar directive', function () { expect(bar.attr('aria-valuetext')).toBe('60%'); }); + it('adjusts the "bar" width and aria when max value changes', function() { + $rootScope.max = 200; + $rootScope.$digest(); + + var bar = getBar(0); + expect(bar.css('width')).toBe('11%'); + + expect(bar.attr('aria-valuemin')).toBe('0'); + expect(bar.attr('aria-valuemax')).toBe('200'); + expect(bar.attr('aria-valuenow')).toBe('22'); + expect(bar.attr('aria-valuetext')).toBe('11%'); + }); + it('allows fractional "bar" width values, rounded to two places', function () { $rootScope.value = 5.625; $rootScope.$digest();