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

Commit b983c0d

Browse files
committed
fix(select): rollback number parsing on value attr
closes #4615 As per the discussion in #4615, please use `ng-value` if you need a non-string value from an md-option for the `ng-model` of a select.
1 parent b1b2c06 commit b983c0d

File tree

2 files changed

+1
-10
lines changed

2 files changed

+1
-10
lines changed

src/components/select/select.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ function OptionDirective($mdButtonInkRipple, $mdUtil) {
673673
if (angular.isDefined(attr.ngValue)) {
674674
scope.$watch(attr.ngValue, setOptionValue);
675675
} else if (angular.isDefined(attr.value)) {
676-
setOptionValue(isNaN(attr.value) ? attr.value : Number(attr.value));
676+
setOptionValue(attr.value);
677677
} else {
678678
scope.$watch(function() {
679679
return element.text();

src/components/select/select.spec.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,6 @@ describe('<md-select>', function() {
9191
//expect($document[0].activeElement).toBe(select[0]);
9292
}));
9393

94-
it('should not convert numbers to strings', inject(function($compile, $rootScope) {
95-
$rootScope.value = 1;
96-
$compile('<md-select ng-model="value">' +
97-
'<md-option ng-repeat="value in [1, 2, 3]" value="{{value}}">{{value}}</md-option>' +
98-
'</md-select>')($rootScope);
99-
$rootScope.$digest();
100-
expect($rootScope.value).toBe(1);
101-
}));
102-
10394
describe('input container', function() {
10495
it('should set has-value class on container for non-ng-model input', inject(function($rootScope, $document) {
10596
var el = setupSelect('ng-model="$root.model"', [1, 2, 3]);

0 commit comments

Comments
 (0)