Skip to content
This repository was archived by the owner on Jan 27, 2018. It is now read-only.

Commit b957405

Browse files
committed
Fix getSelectedItems function if option is object.
1 parent 2f64133 commit b957405

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

angular-selectize.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,15 @@
130130

131131
function getSelectedItems(model) {
132132
model = typeof model === 'string' ? [model] : model || [];
133+
var _hash = [], _hashKeyPrefix = '10768194-ADE3-448E-96D8-65082A7B8D89';
133134
var selections = scope.$parent[optionsProperty].reduce(function(selected, option, index) {
134135
var optionValue = getOptionValue(option);
135136
if (model.indexOf(optionValue) >= 0) {
137+
if ( typeof optionValue == "object" ) {
138+
if ( _hash.indexOf(optionValue) === -1 ) _hash.push(optionValue);
139+
// prefix is needed if selections contains objects and primitives.
140+
optionValue = _hashKeyPrefix + _hash.length
141+
}
136142
selected[optionValue] = index;
137143
}
138144
return selected;

0 commit comments

Comments
 (0)