Angular2:如何通过外部站点上的操作发布和重定向表单 [英] Angular2: how to post+redirect form with action on external site

查看:83
本文介绍了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,然后订阅promise,然后重定向.但是,该重定向如何处理我要通过表单提交的数据?

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?

欢迎任何指针,谢谢. 雷切尔(Rachel)

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处理.这使我回到了Submit按钮的标准用法,并且得到了我需要的行为.

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.

这篇关于Angular2:如何通过外部站点上的操作发布和重定向表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆