0

Question: Can I forward to an angular page from a non-angular page and pass couple of parameters from the non-angular page using form submit (post).

Non Angular page (page 1) with a form (param1 and param2) -> Submit form to an angular page URL (page 2). How can I access the param1 and param2 in page 2?

Flow would be like,

  1. A non-angular page with a form like below
  2. Submit the form to an angular page URL

In #2, can angular be able to read off the parameters passed in the post request.

HTML form submit (lets say with two input params)

<form method="POST" action="<angularPageURL>">
   <input type="text" name="param1" value="1" />
   <input type="text" name="param2" value="ABC" />
   <input type="submit" value="Submit to Angular Page" />
</form>
Daniel
  • 3,541
  • 3
  • 33
  • 46
Selvakumar Arumugam
  • 79,297
  • 15
  • 120
  • 134
  • You cannot submit directly to angular; which is just executed client side. You can however submit to the webserver hosting the angular app, and do actions/redirect accordingly – David Jun 07 '18 at 17:39
  • 1
    The POST method passes its parameters in the body of the HTTP request. You need some server-side code (php, python, nodeJS, etc.) to process the body. If you use the GET method, an AngularJS app can use the `$location` service to examine the parameters encoded in the URL. – georgeawg Jun 07 '18 at 18:10
  • In case you're using angular (not angularjs) and trying @georgeawg's approach may find a solution to get the query params at https://stackoverflow.com/questions/35688084/how-get-query-params-from-url-in-angular2 – Capricorn Jun 07 '18 at 18:14
  • Thanks guys. I think i understand the challenge. The issue is that the parameter sometimes might be big and trying to avoid GET because of the size limit. Dumb question: If processed on the server side, how can i send that information back to angular front end. – Selvakumar Arumugam Jun 07 '18 at 18:24
  • With AngularJS use the `$http` service. With Angular use the `http` service. – georgeawg Jun 07 '18 at 18:25
  • If you are uploading files with a vanilla `
    `, you need to use `enctype="multipart/form-data"`. For more information, see [MDN HTML Reference - `
    ` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form).
    – georgeawg Jun 07 '18 at 18:31

0 Answers0