Skip to content

Commit

Permalink
Issue orizens#17 Addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
danish-jamil committed Aug 13, 2018
1 parent 2dcfde6 commit 488ae6c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/modules/ngx-typeahead.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class NgxTypeAheadComponent implements OnInit, OnDestroy {
@Input() taAllowEmpty = false;
@Input() taCaseSensitive = false;
@Input() taDisplayOnFocus = false;
@Input() taArrayKey = '';
@Input() taTransformResponse: Function;
@Input() taEmptyOnSelect = false;

@Output() taSelected = new EventEmitter<string | any>();
Expand Down Expand Up @@ -191,7 +191,9 @@ export class NgxTypeAheadComponent implements OnInit, OnDestroy {

assignResults(results: any[]) {
const labelForDisplay = this.taListItemLabel;
results = (typeof results === 'object' && this.taArrayKey)?results[this.taArrayKey]:results;
if(this.taTransformResponse){
results = this.taTransformResponse(results);
}
this.resultsAsItems = results;
this.results = results.map(
(item: string | any) => (labelForDisplay ? item[labelForDisplay] : item)
Expand Down

0 comments on commit 488ae6c

Please sign in to comment.