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!

2
  • just don't use angularjs on the form? Commented Feb 27, 2015 at 19:50
  • I am trying to use angularjs directive as components to intergrate with the form, to reused parts.... that is the original intent Commented Feb 27, 2015 at 19:53

1 Answer 1

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>
Sign up to request clarification or add additional context in comments.

3 Comments

I find this hard to understand, please update with a code example
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?
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.