angularjs - Dynamic action in HTML form with POST method -


my webapp must redirect user website on have no control. website expect receive few post parameters user.

without angular, have redirect user using form :

<form method="post" action="https://otherwebsite.com/index.php">    <input type="hidden" name="id" value="a1s2d3">    <input type="hidden" name="number" value="1234567">    <input type="submit" name="submit" value="submit">  </form> 

in angular, work, want action url , value of "number" come angular's scope.

sadly, doesn't seems work when use ng-model or {{var}} in value/action attributes.

any idea redirect user other website posted parameters scope?

here have found simple way of using (kinda uses) angular.

i have angular function

$scope.setaction= function(){     document.myform.action='http://anothersite.com'; }; 

where myform name attribute of form.

<form action="http://asamplesite.com" method="post" name="myform"> 

see fiddle. http://jsfiddle.net/nicolasmoise/f6r9x/

note kinda goes against "angular way" because in view, have no way of seeing logic, it's kinda hidden inside controller. however, stated in question linked to, angular doesn't submitting form old ways. alternative having form call function through ng-submit gets dynamic url , redirecting/reloading (using $location maybe). way might longer @ least logic more evident in view.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -