diff --git a/src/components/select/select.js b/src/components/select/select.js index 4c746de0cf7..5a1f54de27b 100755 --- a/src/components/select/select.js +++ b/src/components/select/select.js @@ -566,7 +566,8 @@ function OptionDirective($mdInkRipple, $mdUtil) { } else if (angular.isDefined(attr.value)) { setOptionValue(attr.value); } else { - throw new Error("Expected either ngValue or value attr"); + debugger; + scope.$watch(function() { return element.text(); }, setOptionValue) } attr.$observe('selected', function(selected) { diff --git a/src/components/select/select.spec.js b/src/components/select/select.spec.js index a823e69f5a8..54c61629ea6 100755 --- a/src/components/select/select.spec.js +++ b/src/components/select/select.spec.js @@ -146,12 +146,20 @@ describe('', function() { })); }); + it('auto-infers a value when none specified', inject(function($rootScope) { + $rootScope.name = "Hannah"; + var el = setup('ng-model="name"', 'Tom' + + 'Hannah'); + expect(selectedOptions(el).length).toBe(1); + })); + it('errors for duplicate md-options, non-dynamic value', inject(function($rootScope) { expect(function() { setup('ng-model="$root.model"', 'Hello' + 'Goodbye'); }).toThrow(); })); + it('errors for duplicate md-options, ng-value', inject(function($rootScope) { setup('ng-model="$root.model"', 'Hello' + 'Goodbye');