处理可重复使用的自定义角度组件

发布于 2025-01-17 17:59:37 字数 245 浏览 1 评论 0原文

我和我的团队是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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深海夜未眠 2025-01-24 17:59:37

您可以为可重用组件创建具有输入和输出的组件。

您只需将选择器包含在要使用该组件的 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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文