@@ -126,13 +126,17 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
126126 return {
127127 restrict : 'E' ,
128128 require : [ 'select' , '?ngModel' ] ,
129- controller : [ '$element' , '$scope' , function ( $element , $scope ) {
129+ controller : [ '$element' , '$scope' , '$attrs' , function ( $element , $scope , $attrs ) {
130130 var self = this ,
131131 optionsMap = { } ,
132132 ngModelCtrl = nullModelCtrl ,
133133 nullOption ,
134134 unknownOption ;
135135
136+
137+ self . databound = $attrs . ngModel ;
138+
139+
136140 self . init = function ( ngModelCtrl_ , nullOption_ , unknownOption_ ) {
137141 ngModelCtrl = ngModelCtrl_ ;
138142 nullOption = nullOption_ ;
@@ -509,6 +513,11 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
509513} ] ;
510514
511515var optionDirective = [ '$interpolate' , function ( $interpolate ) {
516+ var nullSelectCtrl = {
517+ addOption : noop ,
518+ removeOption : noop
519+ } ;
520+
512521 return {
513522 restrict : 'E' ,
514523 priority : 100 ,
@@ -521,11 +530,15 @@ var optionDirective = ['$interpolate', function($interpolate) {
521530 }
522531 }
523532
524- // For some reason Opera defaults to true and if not overridden this messes up the repeater.
525- // We don't want the view to drive the initialization of the model anyway.
526- element . prop ( 'selected' , false ) ;
527-
528533 return function ( scope , element , attr , selectCtrl ) {
534+ if ( selectCtrl . databound ) {
535+ // For some reason Opera defaults to true and if not overridden this messes up the repeater.
536+ // We don't want the view to drive the initialization of the model anyway.
537+ element . prop ( 'selected' , false ) ;
538+ } else {
539+ selectCtrl = nullSelectCtrl ;
540+ }
541+
529542 if ( interpolateFn ) {
530543 scope . $watch ( interpolateFn , function ( newVal , oldVal ) {
531544 attr . $set ( 'value' , newVal ) ;
0 commit comments