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

Commit c727d3f

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

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
@@ -541,19 +541,19 @@
541541

542542
//From model --> view
543543
ngModel.$formatters.unshift(function (inputValue) {
544-
var data = $select.parserResult.source(scope),
544+
var data = $select.parserResult.source (scope, { $select : {search:''}}), //Overwrite $search
545545
locals = {},
546546
result;
547547
if (data){
548548
if ($select.multiple){
549549
var resultMultiple = [];
550-
for (var k = data.length - 1; k >= 0; k--) {
551-
locals = {};
552-
locals[$select.parserResult.itemName] = data[k];
553-
result = $select.parserResult.modelMapper(scope, locals);
554-
for (var j = inputValue.length - 1; j >= 0; j--) {
555-
if (result == inputValue[j]){
556-
resultMultiple.push(data[k]);
550+
for (var k = inputValue.length - 1; k >= 0; k--) {
551+
for (var j = data.length - 1; j >= 0; j--) {
552+
locals = {};
553+
locals[$select.parserResult.itemName] = data[j];
554+
result = $select.parserResult.modelMapper(scope, locals);
555+
if (result == inputValue[k]){
556+
resultMultiple.unshift(data[j]);
557557
break;
558558
}
559559
}

0 commit comments

Comments
 (0)