处理可重复使用的自定义角度组件
我和我的团队是Angular的新手,目前具有创建可重复使用的组件库,可以在项目中使用。
团队为每种类型的输入字段创建角度组件是否常见?例如:emailfieldcomponent,password fieldcomponent,ect ..或类似于角度项目中的常见惯例,因为我无法遇到许多能够将表单控件从父组件附加到任何形式的子女输入的示例字段组件。尤其不是以干净的方式。
还是仅仅让大多数团队都同意将您的所有表单字段放入一个组件并从那里控制验证?
My team and I are new to Angular and currently have the mindset of creating a reusable library of Components to use across projects.
Is it common for teams to create Angular components for each type of input field to reuse? for example: EmailFieldComponent, PasswordFieldComponent, ect.. Or is something like this not common practice in Angular projects since I haven't been able to come across many examples of being able to attach form controls from a parent component to any form of child input field component. Especially not in a clean way.
Or is it just agreed upon for most teams to put all your form fields into one component and controlling validation from there?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以为可重用组件创建具有输入和输出的组件。
您只需将选择器包含在要使用该组件的 html 中即可。
该过程解释如下:
You can create a component with input and output for the reusable component.
You have just to include the selector inside the html you want to use the component.
the procedure is explained here :
https://codehandbook.org/creating-reusable-angular-components/