I recently started using Angular and I found this useful library for select options - https://github.com/NicholasAzar/ng-selectize
Although two-way binding is functional, I am facing difficulty in triggering a function when the select value changes.
Take a look at the following code snippet -
signup.component.html
<ng2-selectize id="date" class="small" name="date" [config]="singleSelectConfig" [options]="dates" placeholder="Date" [(ngModel)]="model.date" required #date="ngModel" ngDefaultControl (change)="updateDate()">
</ng2-selectize>
signup.component.ts
DEFAULT_DROPDOWN_CONFIG: any = {
highlight: false,
create: false,
persist: true,
plugins: ['dropdown_direction', 'remove_button'],
dropdownDirection: 'down'
};
SINGLE_SELECT_PRESET_VALUE_CONFIG = Object.assign({}, this.DEFAULT_DROPDOWN_CONFIG, {
labelField: 'value',
valueField: 'id',
searchField: ['value']
});
singleSelectConfig: any = this.SINGLE_SELECT_PRESET_VALUE_CONFIG;
updateDate() {
// Execute desired functionality here
}