diff --git a/src/app/components/autocomplete/autocomplete.ts b/src/app/components/autocomplete/autocomplete.ts index a729d4c4907..50769aa8f88 100755 --- a/src/app/components/autocomplete/autocomplete.ts +++ b/src/app/components/autocomplete/autocomplete.ts @@ -41,11 +41,25 @@ export const AUTOCOMPLETE_VALUE_ACCESSOR: any = {
@@ -124,6 +138,8 @@ export class AutoComplete implements AfterViewChecked,AfterContentInit,OnDestroy @Input() unique: boolean = true; + @Input() group: boolean; + @Input() completeOnFocus: boolean = false; @Output() completeMethod: EventEmitter = new EventEmitter(); @@ -170,6 +186,10 @@ export class AutoComplete implements AfterViewChecked,AfterContentInit,OnDestroy @Input() autocomplete: string = 'off'; + @Input() optionGroupChildren: string; + + @Input() optionGroupLabel: string; + @ViewChild('container') containerEL: ElementRef; @ViewChild('in') inputEL: ElementRef; @@ -187,6 +207,8 @@ export class AutoComplete implements AfterViewChecked,AfterContentInit,OnDestroy itemTemplate: TemplateRef; selectedItemTemplate: TemplateRef; + + groupTemplate: TemplateRef; value: any; @@ -307,6 +329,10 @@ export class AutoComplete implements AfterViewChecked,AfterContentInit,OnDestroy this.itemTemplate = item.template; break; + case 'group': + this.groupTemplate = item.template; + break; + case 'selectedItem': this.selectedItemTemplate = item.template; break; @@ -325,6 +351,14 @@ export class AutoComplete implements AfterViewChecked,AfterContentInit,OnDestroy this.cd.markForCheck(); } + getOptionGroupChildren(optionGroup: any) { + return this.optionGroupChildren ? ObjectUtils.resolveFieldData(optionGroup, this.optionGroupChildren) : optionGroup.items; + } + + getOptionGroupLabel(optionGroup: any) { + return this.optionGroupLabel ? ObjectUtils.resolveFieldData(optionGroup, this.optionGroupLabel) : (optionGroup.label != undefined ? optionGroup.label : optionGroup); + } + registerOnChange(fn: Function): void { this.onModelChange = fn; }