So let's say I am posting this form to some web service.
<form name="myForm" id="myForm" method="post" action="https://servicelink.....etc" accept-charset="utf-8">
<input type="hidden" name="accepturl" value="{{$ctrl.accepturl}}" ng-model="$ctrl.accepturl">
<input type="hidden" name="callbackurl" value="{{$ctrl.callbackurl}}" ng-model="$ctrl.callbackurl">
<input type="hidden" name="orderid" value="{{$ctrl.orderid}}" ng-model="$ctrl.orderid">
</form>
Here is my Angular controller: (I'm using AngularJS 1.5.8 with components)
function controller(someservice) {
var ctrl = this;
ctrl.accepturl = $window.location.href;
ctrl.callbackurl = "https://........";
ctrl.placeOrder = function () {
someservice.placeOrder(ctrl.amount).then(onOrderInitiation, onOrderInitiationError);
}; //$http.post call is made there
function onOrderInitiation(data) {
ctrl.orderid = data;
// I tried to set the input value by javascript as well with no success
// document.getElementsByName('orderid').value = data;
document.getElementById("flexwinSubmit").submit();
}
}
here is the service where $http.post is done:
this.placeOrder = function(amount){
return $http.post("/rest/.........)
.then(function(response){
return response.data.orderId;
});
};
So I have to update orderid input value in my html from the promise function data (onOrderInitiation) then submit the form. But I couldn't get it updated by any means. However ctrl.orderid is set correctly (I validated that in the logs.)
When I tried to set it the JavaScript way, the value is changed correctly -- when i console.log it. But when submitting the form, the value will not be set.
document.getElementsByName('orderid').value = data;