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

Commit 1276795

Browse files
committed
Fix: when pressing a key on the input, the whole selected array is erased
1 parent 1dc1133 commit 1276795

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/select.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -539,19 +539,19 @@
539539

540540
//From model --> view
541541
ngModel.$formatters.unshift(function (inputValue) {
542-
var data = $select.parserResult.source(scope),
542+
var data = $select.parserResult.source (scope, { $select : {search:''}}), //Overwrite $search
543543
locals = {},
544544
result;
545545
if (data){
546546
if ($select.multiple){
547547
var resultMultiple = [];
548-
for (var k = data.length - 1; k >= 0; k--) {
549-
locals = {};
550-
locals[$select.parserResult.itemName] = data[k];
551-
result = $select.parserResult.modelMapper(scope, locals);
552-
for (var j = inputValue.length - 1; j >= 0; j--) {
553-
if (result == inputValue[j]){
554-
resultMultiple.push(data[k]);
548+
for (var k = inputValue.length - 1; k >= 0; k--) {
549+
for (var j = data.length - 1; j >= 0; j--) {
550+
locals = {};
551+
locals[$select.parserResult.itemName] = data[j];
552+
result = $select.parserResult.modelMapper(scope, locals);
553+
if (result == inputValue[k]){
554+
resultMultiple.unshift(data[j]);
555555
break;
556556
}
557557
}

0 commit comments

Comments
 (0)