In my angular 5 application I need to submit a hidden form programmatically after an Http GET call, but when the form is submitted the three variables I am sending seems empty (but they don't).
In my component I have :
@ViewChild('testForm') testFormEl: any;
this.ticketService.postTicketWithCreditPayment(param)
.subscribe(res => {
this.paymentUrl = res.url;
this.paymentXml = res.xml;
this.paymentHash = res.hash;
console.log(this.paymentUrl) <-- this log make me see the correct paymentUrl
this.testFormEl.nativeElement.submit();
})
}
And in my html I have the form with 3 hidden fields
<form #testForm name="form1" action="https://...url..." method="post">
<input type="hidden" name="url" [value]="paymentUrl">
<input type="hidden" name="xml" [(ngModel)]="paymentXml">
<input type="hidden" name="hash" [(ngModel)]="paymentHash">
</form>
I try binding with [value] and [(ngModel)] but the form submitted is always this:

Is probably related to : stackoverflow
FromBuilder. 2- Link it to the template. 3- When click on submit useHttpClient's appropriate http function to sendform.valuesto the backend.