Skip to content
This repository was archived by the owner on Oct 5, 2019. It is now read-only.

Commit 7450bff

Browse files
author
Robert Michalski
committed
Added an extra check to set value to the defauilt when range is true. Cleaned up some duplicate code for setting options.value.
1 parent 453e3f6 commit 7450bff

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

slider.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,6 @@ angular.module('ui.bootstrap-slider', [])
5858
setBooleanOption('naturalarrowkeys', attrs.naturalarrowkeys, false);
5959
setBooleanOption('reversed', attrs.reversed, false);
6060

61-
if ($scope.value) {
62-
if (angular.isNumber($scope.value) || angular.isArray($scope.value)) {
63-
options.value = $scope.value;
64-
}
65-
else if (angular.isString($scope.value)) {
66-
options.value = getArrayOrValue($scope.value);
67-
if(!angular.isArray(options.value)) {
68-
options.value = parseFloat($scope.value);
69-
}
70-
}
71-
}
72-
7361
setBooleanOption('range', $scope.range, false);
7462
if( options.range ) {
7563
if( angular.isArray($scope.value) ) {
@@ -79,6 +67,8 @@ angular.module('ui.bootstrap-slider', [])
7967
options.value = getArrayOrValue($scope.value);
8068
if(!angular.isArray(options.value)) {
8169
var value = parseFloat($scope.value);
70+
if( isNaN(value) ) value = 5;
71+
8272
if( value < $scope.min ) {
8373
value = $scope.min;
8474
options.value = [value, options.max];
@@ -87,6 +77,9 @@ angular.module('ui.bootstrap-slider', [])
8777
value = $scope.max;
8878
options.value = [options.min, value];
8979
}
80+
else {
81+
options.value = [options.min, options.max];
82+
}
9083
}
9184
}
9285
else {

0 commit comments

Comments
 (0)