Skip to content

Commit

Permalink
Check if items exists before find (DSchrupert#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
BenevidesLecontes authored and NicholasAzar committed Dec 2, 2017
1 parent a1ab7b4 commit 3f716fa
Show file tree
Hide file tree
Showing 2 changed files with 243 additions and 423 deletions.
2 changes: 1 addition & 1 deletion src/ng-selectize.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export class NgSelectizeComponent implements OnInit, OnChanges, DoCheck, Control
const valueField = this.getValueField();
if (this.value) {
const items = typeof this.value === 'string' ? [this.value] : this.value;
if (items.find(value => value === option[valueField])) {
if (items && items instanceof Array && items.find(value => value === option[valueField])) {
this.selectize.addItem(option[valueField], true);
}
}
Expand Down
Loading

0 comments on commit 3f716fa

Please sign in to comment.