I'm facing a tricky problem: I have to make an old style form with action attribute inside a ng-form.
The reason I'm doing this is that the POST request from the old-style form goes to another website, and the user should be "redirected" (in a new page actually) to the result of the POST request (which makes kind of login).
I can simulate the old-style form from javascript but so the browser popup blocker will catch it and it has to be as easy as clicking a link.
I can't touch the outter ng-form because it comes from a framework.
So what I have is:
<div ng-form>
...
...
<form action="old_website.com/index.php" method="post" target="_blank">
<input type="hidden" name="field1" value="value1">
<input type="submit" value="Submit">
</form>
...
...
</div>
I can't find a way to make this work :) Hope you can help.
[edit] Ok I feel stupid. It seems you can have a button that calls a function to simulate and submit the form without having trouble with the browser popup blocker...
It also seems it does not work with Firefox.
What I'm doing is:
HTML:
<button ng-click="submitForm()">Submit</button>
JS:
$scope.submitForm = function() {
var form = $('<form>', {
action: 'old_website.com/index.php',
type: 'post',
target: '_blank'
});
form.append($('<input>', {name: 'field1', value: 'value1'}));
form.submit();
}