[英]How to call a function on value change while using ng-selectize?
I am new to angular and I am using this library for select options - https://github.com/NicholasAzar/ng-selectize 我是angular的新手,我正在使用该库来选择选项-https: //github.com/NicholasAzar/ng-selectize
Two-way binding is working but I am not able to call a function when the value is changed. 双向绑定正在工作,但是更改值后无法调用函数。
Here is the code - 这是代码-
signup.component.html 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 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() {
// call this function
}
Use ngModelChange
: 使用
ngModelChange
:
[(ngModel)]="model.date" (ngModelChange)="dateChanged($event)"
Where $event
is the new model. $event
是新模型。 You can also access it via this.model.date
in the component of course. 您当然也可以通过组件中的
this.model.date
访问它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.