如何手动触发形式在AngularJS提交? [英] How to manually trigger a form's submit in AngularJS?
本文介绍了如何手动触发形式在AngularJS提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有我想要的嵌套形式,但由于HTML不能接受嵌套形式,它是不可能的。有没有一种方法,我可以手动调用提交(触发验证,如需要)第一种形式对AngularJS?
I have a form that I wanted be nested, but it is not possible since HTML can't accept nested form. Is there a way I can manually invoke the submit(triggers the validation, e.g. required) on first form on AngularJS?
这里的code的样子:
Here's how the code looks like:
<div ng-conroller="ContactController">
<form ng-submit="saveHeaderAndDetail()">
<label for="Description">Description</label>
<input type="text" ng-model="Description" required/>
<input type="text" style="visibility:hidden" />
</form>
<form ng-submit="addToDetail()">
...
</form>
<input type="button"
ng-click="what code could trigger the first form's submit?"/>
</div>
顺便说一句,两种形式都包括在一个控制器是否有帮助
Btw, both forms are under one controller if that helps
推荐答案
尝试创建映入事件的指令: http://jsfiddle.net / unWF3 /
Try creating a directive that catches an event: http://jsfiddle.net/unWF3/
这篇关于如何手动触发形式在AngularJS提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文