Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
fix(select): rollback number parsing on value attr
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rschmukler committed Sep 28, 2015
1 parent b1b2c06 commit b983c0d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
2 changes: 1 addition & 1 deletion src/components/select/select.js
Expand Up @@ -673,7 +673,7 @@ function OptionDirective($mdButtonInkRipple, $mdUtil) {
if (angular.isDefined(attr.ngValue)) {
scope.$watch(attr.ngValue, setOptionValue);
} else if (angular.isDefined(attr.value)) {
setOptionValue(isNaN(attr.value) ? attr.value : Number(attr.value));
setOptionValue(attr.value);
} else {
scope.$watch(function() {
return element.text();
Expand Down
9 changes: 0 additions & 9 deletions src/components/select/select.spec.js
Expand Up @@ -91,15 +91,6 @@ describe('<md-select>', function() {
//expect($document[0].activeElement).toBe(select[0]);
}));

it('should not convert numbers to strings', inject(function($compile, $rootScope) {
$rootScope.value = 1;
$compile('<md-select ng-model="value">' +
'<md-option ng-repeat="value in [1, 2, 3]" value="{{value}}">{{value}}</md-option>' +
'</md-select>')($rootScope);
$rootScope.$digest();
expect($rootScope.value).toBe(1);
}));

describe('input container', function() {
it('should set has-value class on container for non-ng-model input', inject(function($rootScope, $document) {
var el = setupSelect('ng-model="$root.model"', [1, 2, 3]);
Expand Down

0 comments on commit b983c0d

Please sign in to comment.