Skip to content

Commit 22f67aa

Browse files
committed
Sets ngModel as an empty array if it's undefined
1 parent 0748465 commit 22f67aa

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Diff for: src/select.js

+1
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,7 @@
580580
}
581581
return false;
582582
};
583+
if (!inputValue) return resultMultiple; //If ngModel was undefined
583584
for (var k = inputValue.length - 1; k >= 0; k--) {
584585
if (!checkFnMultiple($select.selected, inputValue[k])){
585586
checkFnMultiple(data, inputValue[k]);

Diff for: test/select.spec.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ describe('ui-select tests', function() {
2323
$timeout = _$timeout_;
2424
scope.selection = {};
2525

26-
//TESTME
27-
scope.selection.selectedMultiple = [];
28-
2926
scope.getGroupLabel = function(person) {
3027
return person.age % 2 ? 'even' : 'odd';
3128
};
@@ -755,6 +752,15 @@ describe('ui-select tests', function() {
755752
expect(el.find('.ui-select-match-item').length).toBe(0);
756753
});
757754

755+
it('should set model as an empty array if ngModel isnt defined', function () {
756+
757+
// scope.selection.selectedMultiple = [];
758+
var el = createUiSelectMultiple();
759+
760+
expect(scope.selection.selectedMultiple instanceof Array).toBe(true);
761+
762+
});
763+
758764
it('should render initial selected items', function() {
759765
scope.selection.selectedMultiple = [scope.people[4], scope.people[5]]; //Wladimir & Samantha
760766
var el = createUiSelectMultiple();

0 commit comments

Comments
 (0)