简体   繁体   English

ngModelOptions的angular的updateOn属性支持的完整事件列表是什么?

[英]What is the complete list of events supported by angular's updateOn property of ngModelOptions?

The docs say 文档

updateOn: string specifying which event should the input be bound to. updateOn:指定输入绑定到哪个事件的字符串。 You can set several events using an space delimited list. 您可以使用空格分隔列表设置多个事件。 There is a special event called default that matches the default events belonging of the control. 有一个名为default的特殊事件与属于控件的默认事件匹配。

The page mentions a few events: blur , default , submit . 该页面提到了一些事件: blurdefaultsubmit Are there any others? 还有其他人吗? Is the full list documented anywhere? 完整列表是否记录在何处?

As far as i know, you can bind any available DOM event to the updateOn property. 据我所知,您可以将任何可用的DOM事件绑定到updateOn属性。 see a full list here . 在这里查看完整列表。

Having a look at the Source of ngModel , you can see that the options passed to updateOn will get bound to the actual element itself. 看一下ngModel的源ngModel ,您可以看到传递给updateOn的选项将绑定到实际的元素本身。

https://github.com/angular/angular.js/blob/master/src/ng/directive/ngModel.js#L1188 https://github.com/angular/angular.js/blob/master/src/ng/directive/ngModel.js#L1188

Angular Source: 角度来源:

if (modelCtrl.$options.getOption('updateOn')) {
  element.on(modelCtrl.$options.getOption('updateOn'), function(ev) {
    modelCtrl.$$debounceViewValueCommit(ev && ev.type);
  });
}

You can now control for a form (or single form elements) when the value or the validity is updated. 现在,您可以在更新值或有效性时控制表单(或单个表单元素)。 This feature has been available in AngularJS 1.x but missed in Angular 2+ so far. 此功能已在AngularJS 1.x中提供,但到目前为止在Angular 2+中未使用。 The following update options can now be used in Angular 5 forms: 现在可以在Angular 5表单中使用以下更新选项:

change : change is the default mode. 更改 :更改是默认模式。 By using this update option the form / form control is updated after every single change. 通过使用此更新选项,每次更改后都会更新表单/表单控件。

blur : the blur change mode is only updated the from values / validity status after a form control lost the focus. 模糊 :模糊更改模式仅在表单控件丢失焦点后从值/有效性状态更新。

submit : updates are only done after form submit. 提交 :更新仅在表单提交后完成。

Full source is here . 完整的来源在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM