Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

Commit

Permalink
fix: Error in console when value in model = undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
Hervé TINANT committed Jul 12, 2017
1 parent c93edbf commit 2544f0d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/lib/src/service/select.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,16 @@ export class SelectService {

private getItemForModel(value: any, array: SelectableItem[]): SelectableItem[] {
let result: SelectableItem[] = [];
array.forEach(v => {
if (v.id === value[this.Configuration.idProperty].toString()) {
result.push(v);
for (let v of array) {
if (value && value[this.Configuration.idProperty]) {
if (v.id === (value[this.Configuration.idProperty] || '').toString()) {
result.push(v);
}
}
if (this.Configuration.isHierarchy() && v.children && v.children.length > 0) {
result = [...result, ...this.getItemForModel(value, v.children)];
}
});
};
return result;
}
}

0 comments on commit 2544f0d

Please sign in to comment.