Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit cc9198e

Browse files
committed
fix(multiple): prevent $select.selected with incorrect values from formatter
1 parent ed61077 commit cc9198e

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/uiSelectMultipleDirective.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,7 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec
7979
if (data){
8080
var resultMultiple = [];
8181
var checkFnMultiple = function(list, value){
82-
//if the list is empty add the value to the list
83-
if (!list || !list.length){
84-
resultMultiple.unshift(value);
85-
return true;
86-
}
82+
if (!list || !list.length) return;
8783
for (var p = list.length - 1; p >= 0; p--) {
8884
locals[$select.parserResult.itemName] = list[p];
8985
result = $select.parserResult.modelMapper(scope, locals);
@@ -103,7 +99,9 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec
10399
};
104100
if (!inputValue) return resultMultiple; //If ngModel was undefined
105101
for (var k = inputValue.length - 1; k >= 0; k--) {
102+
//Check model array of currently selected items
106103
if (!checkFnMultiple($select.selected, inputValue[k])){
104+
//Check model array of all items available
107105
checkFnMultiple(data, inputValue[k]);
108106
}
109107
}

0 commit comments

Comments
 (0)