From 7ccff028ff5ed19af63d9cf1f5e078223924f3a0 Mon Sep 17 00:00:00 2001 From: Raanan Weber Date: Mon, 9 Feb 2015 14:13:58 +0100 Subject: [PATCH] feat(progressbar): allow dynamic update to max - Adds ability to dynamically change max value --- src/progressbar/progressbar.js | 6 ++++-- src/progressbar/test/progressbar.spec.js | 9 ++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/progressbar/progressbar.js b/src/progressbar/progressbar.js index 9a6a6355d7..3cb855e53d 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($attrs.max) ? $scope.$parent.$eval($attrs.max) : progressConfig.max; + $scope.max = angular.isDefined($scope.max) ? $scope.max : progressConfig.max; this.addBar = function(bar, element) { if ( !animate ) { @@ -54,6 +54,7 @@ angular.module('ui.bootstrap.progressbar', []) require: '^progress', scope: { value: '=', + max: '=?', type: '@' }, templateUrl: 'template/progressbar/bar.html', @@ -71,6 +72,7 @@ angular.module('ui.bootstrap.progressbar', []) controller: 'ProgressController', scope: { value: '=', + max: '=?', type: '@' }, templateUrl: 'template/progressbar/progressbar.html', @@ -78,4 +80,4 @@ angular.module('ui.bootstrap.progressbar', []) progressCtrl.addBar(scope, angular.element(element.children()[0])); } }; -}); \ No newline at end of file +}); diff --git a/src/progressbar/test/progressbar.spec.js b/src/progressbar/test/progressbar.spec.js index c4d4f2a78a..fef4f4accd 100644 --- a/src/progressbar/test/progressbar.spec.js +++ b/src/progressbar/test/progressbar.spec.js @@ -116,6 +116,13 @@ describe('progressbar directive', function () { it('transcludes "bar" text', function() { expect(getBar(0).text()).toBe('22/200'); }); + + it('adjusts the valuemax when it changes', function() { + expect(getBar(0).attr('aria-valuemax')).toBe('200'); + $rootScope.max = 300; + $rootScope.$digest(); + expect(getBar(0).attr('aria-valuemax')).toBe('300'); + }); }); describe('"type" attribute', function () { @@ -209,4 +216,4 @@ describe('progressbar directive', function () { expect(getBar(0)).not.toHaveClass(BAR_CLASS + '-warning'); }); }); -}); \ No newline at end of file +});