Domanda

My angular application needs to submit a form to a vendor. They then redirect the user to a page that I specified earlier in the process.

So I want standard, non-angular html form submit behaviour.

The documentation (details below) makes it sound like all I need to do is add an action attribute to my form element. I have tried this and it does not work.

Has anyone used this functionality in angular? Is there another step that I am missing?


The relevant section of the documentation at https://docs.angularjs.org/api/ng/directive/form is:

Submitting a form and preventing the default action Since the role of forms in client-side Angular applications is different than in classical roundtrip apps, it is desirable for the browser not to translate the form submission into a full page reload that sends the data to the server. Instead some javascript logic should be triggered to handle the form submission in an application-specific way.

For this reason, Angular prevents the default action (form submission to the server) unless the element has an action attribute specified.

È stato utile?

Soluzione

Angular does that. When you provide an action on the form, it should do exactly what you're trying to do (do a javascript thing, then submit the form).

Here is a plunk

In the plunk, you can see the $scope.submitted say 'submitted' just before the form submission kicks the page over to the submitted.html

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top