Skip to content
This repository was archived by the owner on Aug 21, 2018. It is now read-only.

Commit 7ccff02

Browse files
RaananWwesleycho
authored andcommitted
feat(progressbar): allow dynamic update to max
- Adds ability to dynamically change max value
1 parent f13ed0f commit 7ccff02

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/progressbar/progressbar.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ angular.module('ui.bootstrap.progressbar', [])
1010
animate = angular.isDefined($attrs.animate) ? $scope.$parent.$eval($attrs.animate) : progressConfig.animate;
1111

1212
this.bars = [];
13-
$scope.max = angular.isDefined($attrs.max) ? $scope.$parent.$eval($attrs.max) : progressConfig.max;
13+
$scope.max = angular.isDefined($scope.max) ? $scope.max : progressConfig.max;
1414

1515
this.addBar = function(bar, element) {
1616
if ( !animate ) {
@@ -54,6 +54,7 @@ angular.module('ui.bootstrap.progressbar', [])
5454
require: '^progress',
5555
scope: {
5656
value: '=',
57+
max: '=?',
5758
type: '@'
5859
},
5960
templateUrl: 'template/progressbar/bar.html',
@@ -71,11 +72,12 @@ angular.module('ui.bootstrap.progressbar', [])
7172
controller: 'ProgressController',
7273
scope: {
7374
value: '=',
75+
max: '=?',
7476
type: '@'
7577
},
7678
templateUrl: 'template/progressbar/progressbar.html',
7779
link: function(scope, element, attrs, progressCtrl) {
7880
progressCtrl.addBar(scope, angular.element(element.children()[0]));
7981
}
8082
};
81-
});
83+
});

src/progressbar/test/progressbar.spec.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ describe('progressbar directive', function () {
116116
it('transcludes "bar" text', function() {
117117
expect(getBar(0).text()).toBe('22/200');
118118
});
119+
120+
it('adjusts the valuemax when it changes', function() {
121+
expect(getBar(0).attr('aria-valuemax')).toBe('200');
122+
$rootScope.max = 300;
123+
$rootScope.$digest();
124+
expect(getBar(0).attr('aria-valuemax')).toBe('300');
125+
});
119126
});
120127

121128
describe('"type" attribute', function () {
@@ -209,4 +216,4 @@ describe('progressbar directive', function () {
209216
expect(getBar(0)).not.toHaveClass(BAR_CLASS + '-warning');
210217
});
211218
});
212-
});
219+
});

0 commit comments

Comments
 (0)