Angular2:如何在外部站点上发布+重定向表单并执行操作
我在 Angular2 网页上有一个表单.
I have a form on an Angular2 webpage.
当我在表单上点击提交时,我希望method="post".....> 等价物发生.
When I hit submit on the form, I'd like the equivalent of " method="post".....> to happen.
也就是说,表单的操作脚本位于另一个网站上,我只想将表单发布到该网站.然后在那个外部网站上.
That is, the action script for the form is on another website, and I'd like to just post the form to that website. And to then be on that external site.
我正在用头撞砖墙;提交"按钮似乎已被 Angular 接管,因此只需点击提交"就没有任何作用.当我需要异步处理数据时,我知道如何执行此操作,但当我只想移动到该外部站点时不知道如何执行此操作.
I'm beating my head against a brick wall on this; the Submit button appears to have been taken over by Angular, so just hitting Submit does nothing. I know how to do this when I need to handle the data asynchronously, but not when I want to just move to that external site.
我不需要任何花哨的 Angular 验证等,只需将表单发布到外部站点,然后在该站点上即可.
I don't need any fancy Angular validation, etc, just to post the form to the external site, and then be on that site.
我一直在阅读和谷歌搜索,提供的唯一建议似乎是做一个 http.post,然后订阅承诺,然后重定向.但是该重定向如何处理我想与表单一起提交的数据?
I've been reading and googling, and the only suggestion offered appears to be doing a http.post, then subscribing to the promise, then redirecting. But how does that redirect handle the data I want to submit with the form?
欢迎指点,谢谢.雷切尔
Any pointers welcome, thanks. Rachel
多亏了 angular2-forms 标签在我发布这篇文章时显示为一个选项,我想我已经在 Angular2 ngNoForm 并进行角度表单验证
Thanks to the angular2-forms tag which showed up as an option when I posted this, I think I have found the answer at Angular2 ngNoForm and also do angular form validation
ngForm "ngNoForm" 上有一个(相当未记录的)选项,它从这个特定的表单中删除了自动 ngForm 处理.这让我恢复了提交按钮的标准用法,并获得了我需要的行为.
There is a (rather undocumented) option on ngForm "ngNoForm" which removes the automatic ngForm handling from this specific form. This gives me back the standard use of the Submit button, and gets the behaviour I need.