| title | Combo Templates |
|---|---|
| description | Custom templates for different areas of the igx-combo component can be defined, including items, header, footer, empty list and adding button. |
| keywords | Ignite UI for Angular, UI controls, Angular widgets, web widgets, UI widgets, Angular, Native Angular Components Suite, Native Angular Controls, Native Angular Components Library, Angular Combo components, Angular Templates, Angular Combo Templates |
| _language | kr |
Custom templates for different areas of the igx-combo component can be defined, including items, header, footer, empty list and adding button.
To get started with the Ignite UI for Angular Combo import the IgxComboModule in the app.module.ts file:
// app.module.ts
...
import { IgxComboModule } from 'igniteui-angular';
@NgModule({
...
imports: [..., IgxComboModule],
...
})
export class AppModule {}Defining templates for item, header, footer and empty one is achieved using predefined reference names (see the topic below for detailed information):
<igx-combo #templateCombo [data]="lData" [valueKey]="'field'" >
<ng-template igxComboItem let-display let-key="valueKey">
<div class="item">
<span class="state">{{ display[key] }} - </span>
<span class="region">{{ display.region }}</span>
</div>
</ng-template>
<ng-template igxComboHeader>
<div class="header-class">State - Region</div>
</ng-template>
<ng-template igxComboFooter>
<div class="footer-class">Infragistics 2018</div>
</ng-template>
<igx-combo>
<ng-template igxComboEmpty>
<span class="empty-class">No available states</span>
</ng-template>
</igx-combo>
</igx-combo>When defining one of the templates below, you need to reference them using the following predefined names:
Use selector [igxComboItem]:
<igx-combo>
<ng-template igxComboItem let-display let-key="valueKey">
<div class="item">
<span class="state">State: {{ display[key] }}</span>
<span class="region">Region: {{ display.region }}</span>
</div>
</ng-template>
</igx-combo>Use selector [igxComboHeader]:
<igx-combo>
<ng-template igxComboHeader>
<div class="header-class">Custom header</div>
<img src/>
</ng-template>
</igx-combo>Use selector [igxComboFooter]:
<igx-combo>
<ng-template igxComboFooter>
<div class="footer-class">Custom footer</div>
<img src/>
</ng-template>
</igx-combo>Use selector [igxComboEmpty]:
<igx-combo>
<ng-template igxComboEmpty>
<span>List is empty</div>
</ng-template>
</igx-combo>Use selector [igxComboAddItem]:
<igx-combo>
<ng-template igxComboAddItem>
<span>Add town</span>
</ng-template>
</igx-combo>Use selector [igxComboToggleIcon]:
<igx-combo>
<ng-template igxComboToggleIcon let-collapsed>
<igx-icon>{{ collapsed ? 'remove_circle' : 'remove_circle_outline'}}</igx-icon>
</ng-template>
</igx-combo>Use selector [igxComboClearIcon]:
<igx-combo>
<ng-template igxComboClearIcon>
<igx-icon>music_off</igx-icon>
</ng-template>
</igx-combo>The above-mentioned selectors, [igxComboClearIcon] and [igxComboToggleIcon], used with templates will change how the respective buttons appear in the combo input.
Passing content inside of the igx-combo also allows templating of the combo input similar to the way an igx-input-group can be templated (using igx-prefix, igx-suffix and [igxLabel]). The code snippet below illustrates how to add an appropriate label and igx-prefix to the combo input, as well as changing the clear button icon:
<igx-combo [data]="myMusic">
...
<label igxLabel>Genres</label>
<igx-prefix><igx-icon>music_note</igx-icon></igx-prefix>
<ng-template igxComboClearIcon>
<igx-icon>music_off</igx-icon>
</ng-template>
...
</igx-combo>- Combo Features
- Combo Remote Binding
- Template Driven Forms Integration
- Reactive Forms Integration
- Single Select ComboBox
Our community is active and always welcoming to new ideas.