I am getting the form values as undefined upon form submit.
@ViewChild('someForm', { static: true }) form: ElementRef<HTMLFormElement>;
public apiReponse: JsonResponse;
this.route.queryParams
.pipe(
switchMap((params) =>
this.authService.getToken$(
param1, param2
)
),
first(),
takeUntil(this.ngUnsubscribe$)
)
.subscribe({
next: (returnJson) => {
const responseObj = JSON.parse(returnJson);
this.apiReponse = responseObj;
console.log('response', this.apiReponse);
console.log('this form', this.form.nativeElement);
this.form.nativeElement.submit();
},
error: () => {
console.log('Some error ');
},
});
and my form is
<form
#someForm
ngNoForm
method="post"
enctype="application/x-www-form-urlencoded"
>
<input type="hidden" id="token" name="token" [value]="apiReponse?.token" />
</form>