如何做到表单提交与Angularjs PHP的方式? [英] How to do form submit the PHP way with Angularjs?

查看:157
本文介绍了如何做到表单提交与Angularjs PHP的方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现,<一个href=\"http://stackoverflow.com/questions/23813413/how-to-programmatically-submit-a-form-with-angularjs\">AngularJS排序受阻提交和<一个原始形态的方法href=\"http://stackoverflow.com/questions/25823716/angularjs-disabling-forms-when-controllers-are-created\">here是另外一个。我自己,找到了自己的麻烦,因为我需要许多遗留工作提交其使用的页面刷新后提交表单的方式PHP形式来传递$ _REQUESTs而不是JavaScript的Ajax调用,比如$邮寄或$搞定。

I found out that AngularJS sort of blocked the original form's way of submit and here is another one. Myself, found its troublesome because I need to work with many legacy submit form which use PHP way of submitting form after page refresh to pass $_REQUESTs instead of the javascript ajax call like $post or $get.

我知道它不好不无刷新提交。然而,为了应付在网页的作品,我需要如何本来做提交的PHP方式,换言之,形式预期的页面之后加载与参数在同一页传递回本身与附加的参数的方式网址。 (即一个网页的index.php将成为的index.php?AVAR = 123,让我们假设submited形式包含$ _REQUEST ['AVAR']输入值。

I know its bad to not submit without refresh. however, to cope with the way how originally the page works, I need to do the submit the "PHP way", in other words, the form is expected to load the same page with parameter passed back to itself with additional parameter after the page url. (i.e. a page index.php will become index.php?aVar=123, lets assume the submited the form contain a $_REQUEST['aVar'] input value.

任何帮助将是巨大的!最后的结果,只要有点网页得到了重新装入表单的输入成为页参数将是足够的!

Any help will be great! Final result as long as somewhat the page got reloaded with the form's inputs become parameter for the page will be sufficient!

感谢您

推荐答案

啊哈!下面是一个简单的变通!

Ah HA! Here is an easy work around!

所以,要确保包括在NG-应用程序中使用angularjs,是不是适用于这些形式的输入字段的&LT;形式&gt;在DOM的的水平!很重要!所以,现在,NG-应用程序可以在一个正常的PHP的方式使用中的形式:D

so, make sure include those form "input fields" that using angularjs in a ng-app that is NOT applied to the <form> level of the DOM! very important! So now, ng-app can be used WITHIN the form in a "normal PHP way" :D

不能说其工作的每一个人,但它适用于这一塞纳里奥!

Can't say its working for everyone, but it works for this senario!

干杯!

例如


<body>
<form>
<div ng-app="ngComponent">
<!-- Do your Angular stuff here -->
</div>
<div> <!-- Do non angular stuff here --> </div>


</form>
</body>
</html>

这篇关于如何做到表单提交与Angularjs PHP的方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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