@@ -9,7 +9,10 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec
9
9
$select = $scope . $select ,
10
10
ngModel ;
11
11
12
- //Wait for link fn to inject it
12
+ if ( angular . isUndefined ( $select . selected ) )
13
+ $select . selected = [ ] ;
14
+
15
+ //Wait for link fn to inject it
13
16
$scope . $evalAsync ( function ( ) { ngModel = $scope . ngModel ; } ) ;
14
17
15
18
ctrl . activeMatchIndex = - 1 ;
@@ -21,7 +24,7 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec
21
24
22
25
ctrl . refreshComponent = function ( ) {
23
26
//Remove already selected items
24
- //e.g. When user clicks on a selection, the selected array changes and
27
+ //e.g. When user clicks on a selection, the selected array changes and
25
28
//the dropdown should remove that item
26
29
$select . refreshItems ( ) ;
27
30
$select . sizeSearchInput ( ) ;
@@ -123,7 +126,7 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec
123
126
} ;
124
127
if ( ! inputValue ) return resultMultiple ; //If ngModel was undefined
125
128
for ( var k = inputValue . length - 1 ; k >= 0 ; k -- ) {
126
- //Check model array of currently selected items
129
+ //Check model array of currently selected items
127
130
if ( ! checkFnMultiple ( $select . selected , inputValue [ k ] ) ) {
128
131
//Check model array of all items available
129
132
if ( ! checkFnMultiple ( data , inputValue [ k ] ) ) {
@@ -134,8 +137,8 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec
134
137
}
135
138
return resultMultiple ;
136
139
} ) ;
137
-
138
- //Watch for external model changes
140
+
141
+ //Watch for external model changes
139
142
scope . $watchCollection ( function ( ) { return ngModel . $modelValue ; } , function ( newValue , oldValue ) {
140
143
if ( oldValue != newValue ) {
141
144
ngModel . $modelValue = null ; //Force scope model value and ngModel value to be out of sync to re-run formatters
0 commit comments