@@ -126,13 +126,17 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
126
126
return {
127
127
restrict : 'E' ,
128
128
require : [ 'select' , '?ngModel' ] ,
129
- controller : [ '$element' , '$scope' , function ( $element , $scope ) {
129
+ controller : [ '$element' , '$scope' , '$attrs' , function ( $element , $scope , $attrs ) {
130
130
var self = this ,
131
131
optionsMap = { } ,
132
132
ngModelCtrl = nullModelCtrl ,
133
133
nullOption ,
134
134
unknownOption ;
135
135
136
+
137
+ self . databound = $attrs . ngModel ;
138
+
139
+
136
140
self . init = function ( ngModelCtrl_ , nullOption_ , unknownOption_ ) {
137
141
ngModelCtrl = ngModelCtrl_ ;
138
142
nullOption = nullOption_ ;
@@ -509,6 +513,11 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
509
513
} ] ;
510
514
511
515
var optionDirective = [ '$interpolate' , function ( $interpolate ) {
516
+ var nullSelectCtrl = {
517
+ addOption : noop ,
518
+ removeOption : noop
519
+ } ;
520
+
512
521
return {
513
522
restrict : 'E' ,
514
523
priority : 100 ,
@@ -521,11 +530,15 @@ var optionDirective = ['$interpolate', function($interpolate) {
521
530
}
522
531
}
523
532
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
-
528
533
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
+
529
542
if ( interpolateFn ) {
530
543
scope . $watch ( interpolateFn , function ( newVal , oldVal ) {
531
544
attr . $set ( 'value' , newVal ) ;
0 commit comments