简体   繁体   English

如何使用组件和自定义验证来实现Angular 1 Form

[英]How to implement Angular 1 Form with Component and custom validation

I want to implement an angular form that holds a custom component and that uses custom (asynchronous) validation. 我想实现一个包含自定义组件并使用自定义(异步)验证的角度形式。

I was not able to find any documentation on how to implement that based on angular components. 我找不到任何有关如何基于角度组件来实现的文档。

The link function used with the "normal" directive examples is not available for components. 与“普通”指令示例一起使用的链接功能不适用于组件。 The documentation https://code.angularjs.org/1.5.1/docs/guide/forms does only explain how to do this with directives (requiring ngModel and using it in the link function). 文档https://code.angularjs.org/1.5.1/docs/guide/forms仅说明了如何使用指令(要求ngModel并在链接函数中使用它)执行此操作。

How would I do this with angular components? 我该如何使用角度组件呢?

I was also looking for this and ended up here: [ https://github.com/angular-ui/ui-validate] . 我也在寻找它,并最终到达了这里:[ https://github.com/angular-ui/ui-validate]

I find this less invasive anyway, but it doesn't work for encapsulating validation with the element as well. 无论如何,我发现这种方法的侵入性较小,但是对于将验证与元素封装在一起也不起作用。 In those cases I think you will still want to go with a directive as angular's guidelines themselves seem to suggest to use directives where link functions are needed. 在这些情况下,我认为您仍然会希望使用指令,因为angular的准则本身似乎建议在需要链接功能的地方使用指令。

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

相关问题 如何使用Angular JS和Bootstrap进行表单验证? - How to implement form validation with Angular JS and Bootstrap? 如何将自定义验证添加到角度组件? - How to add custom validation to an angular component? 角度自定义表单验证 - Angular custom form validation 如何在Angular 2中使用Typescript类和接口实现“模式”以进行表单验证? - How to implement a “schema” with Typescript classes and interfaces in Angular 2 for form validation? 如何从angular 1.5组件获取表单验证 - how to get form validation from angular 1.5 component 在Angular Form上进行自定义验证-模糊 - Custom validation on Angular Form - on blur 角度自定义表格验证和指令 - Angular Custom Form Validation and Directives 如何在Angular表单上设置自定义验证? - How does one set custom validation on an Angular form? 在以角4反应形式进行控件初始化后,如何添加自定义验证? - How to add custom validation after control initialization in angular 4 reactive form? Angular 反应式 Forms:是否可以创建包含“必须具有”验证的自定义表单控件组件? - Angular Reactive Forms: is it possible to create custom form control component with 'must have' validation included?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM