我正在拿到形式上未定义的形式价值。
@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 );
},
});
我的发言
<form
#someForm
ngNoForm
method="post"
enctype="application/x-www-form-urlencoded"
>
<input type="hidden" id="token" name="token" [value]="apiReponse?.token" />
</form>
```