diff --git a/src/progressbar/progressbar.js b/src/progressbar/progressbar.js index 5a1953bb89..9a6a6355d7 100644 --- a/src/progressbar/progressbar.js +++ b/src/progressbar/progressbar.js @@ -20,7 +20,7 @@ angular.module('ui.bootstrap.progressbar', []) this.bars.push(bar); bar.$watch('value', function( value ) { - bar.percent = Math.round(100 * value / $scope.max); + bar.percent = +(100 * value / $scope.max).toFixed(2); }); bar.$on('$destroy', function() { diff --git a/src/progressbar/test/progressbar.spec.js b/src/progressbar/test/progressbar.spec.js index dd6d994fd4..6b82479b37 100644 --- a/src/progressbar/test/progressbar.spec.js +++ b/src/progressbar/test/progressbar.spec.js @@ -65,6 +65,27 @@ describe('progressbar directive', function () { expect(bar.attr('aria-valuetext')).toBe('60%'); }); + it('allows fractional "bar" width values, rounded to two places', function () { + $rootScope.value = 5.625; + $rootScope.$digest(); + expect(getBar(0).css('width')).toBe('5.63%'); + + $rootScope.value = 1.3; + $rootScope.$digest(); + expect(getBar(0).css('width')).toBe('1.3%'); + }); + + it('does not include decimals in aria values', function () { + $rootScope.value = 50.34; + $rootScope.$digest(); + + var bar = getBar(0); + expect(bar.css('width')).toBe('50.34%'); + + expect(bar.attr('aria-valuenow')).toBe('50'); + expect(bar.attr('aria-valuetext')).toBe('50%'); + }); + describe('"max" attribute', function () { beforeEach(inject(function() { $rootScope.max = 200; diff --git a/template/progressbar/progressbar.html b/template/progressbar/progressbar.html index fade0de2b9..1ba8094704 100644 --- a/template/progressbar/progressbar.html +++ b/template/progressbar/progressbar.html @@ -1,3 +1,3 @@
-
+
\ No newline at end of file