0

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.

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 submitted the form contain a $_REQUEST['aVar'] input value.

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

halfer
  • 19,824
  • 17
  • 99
  • 186
ey dee ey em
  • 7,991
  • 14
  • 65
  • 121

1 Answers1

0

Ah HA! Here is an easy work around!

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!

Cheers!

For example

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


</form>
</body>
</html>
ey dee ey em
  • 7,991
  • 14
  • 65
  • 121
  • I find this hard to understand, please update with a code example – ABCD.ca Jul 30 '15 at 17:53
  • basically, we initiate the ng-app="myApp" ONLY on the section of the DOM that we need to impliment the angular, instead of the WHOLE html page. is that explains it? – ey dee ey em Jul 30 '15 at 20:33
  • I think I see what you mean – you had an angular component within your form but you did not want angular to manage your form. Now your form remains a basic HTML form which can post to PHP without needing JavaScript within your angular app. – ABCD.ca Aug 24 '15 at 23:42