简体   繁体   English

angularjs中另一种表单内的表单组件

[英]form component inside another form in angularjs

I have aa big form in a componentA 我在componentA中有一个很大的形式

inside componentA at some point, I call a componentB. 在某个时候在componentA内部,我称一个componentB。

componentB contain some stuff, and also a form. componentB包含一些东西,还有一种形式。

when I submit componentA form, I submit componentB form. 提交componentA表单时,我将提交componentB表单。

I can check the error and invalid/required input there but, I wish to disable the button to send the form if componentA form or componentB form has invalids value. 我可以在那里检查错误和无效/必需的输入,但是,如果componentA表单或componentB表单具有无效值,我希望禁用该按钮以发送表单。

How can I achieve that? 我该如何实现? I have a relation beetween the component, so do I make a custon "isvalid" function on component A checking booth forms ? 我在组件之间有一个联系,所以我要在组件A上检查一个“无效”功能吗?

did you use Input & Output annotations for passing data and flags to disable and enable buttons and getting values? 您是否使用输入和输出注释传递数据和标志来禁用和启用按钮以及获取值?

if yes, you can make a single submit button in the last step in your logic and sharing global object if they related. 如果是,则可以在逻辑的最后一步中创建一个提交按钮,并共享相关的全局对象。 I suggested your logic will in one component. 我建议您将逻辑放在一个组件中。

Maybe you can use one HTML form like this : 也许您可以使用这样的一种HTML形式:

<form name="myForm">
  <componentA>
    <componentB></componentB>
 </componentA>
</form>

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

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