2

I am in a situation where I have to provide a link of my web app to client & they will be posting form to my web page. The app is created on Angular 5. I have been googling around; but didn't find the the solution. I hope any of you could help me it.

<form action="http://localhost:4200/#/activateaccount" >
    <input type='Hidden' name='loginId' value='ahsan.iqbal@abc.co.uk'/>
    <input type="submit" value="Submit">
</form>

The submission code will be something like this. Where in action the link is of my Angular 5 app. Is it possible to post to Anuglar 5 page?

Thanks in advance though.

Ahsan Iqbal
  • 78
  • 1
  • 4
  • 10
  • 1
    Angular runs on the frontend. Posts requests are sent to a backend application. What you want to do does not make any sense. – Christian Benseler May 21 '18 at 19:40
  • Thanks for your input @ChristianBenseler. Yes, I know Angular runs on front end, but what I want is more like a callback url. My client will redirect the customer to my angular app, but at the same time will submit the form data in hidden filed. I want to process that data, without telling the customer what I am doing at backend. – Ahsan Iqbal May 21 '18 at 20:19
  • I guess you can't retrieve in the frontend the data posted via POST, because the http is stateless. The params passed from one url to another must be on the url (via querystring). – Christian Benseler May 21 '18 at 20:28

1 Answers1

2

Post requests go to a server and Angular won’t see that since it’s running at the client side. You can post to your app’s index.html, but I doubt that’s what you want.

What you want is REST API endpoint that can accept http post.

See

How to receive POST request in an AngularJS page?

External servers posting to angular 2 routes

salah-1
  • 1,299
  • 11
  • 15
  • Thanks for your input @salah. your second link is what I am really looking for. Or I must say it's more like at front I don't wanna show any form posting to customer. But at backend want to post the hidden form data to my API and activate customer account without disclosing the data I am processing. That's data will be posted by my clients in hidden fields. – Ahsan Iqbal May 21 '18 at 20:14
  • Don’t forget to choose an answer :) – salah-1 May 21 '18 at 20:33