angular post method dynamically payment gateway Error : TypeError: this.element.submit is not a function
angular post method dynamically payment gateway Error : TypeError: this.element.submit is not a function
我在 angular
的 html 端创建了 post 方法
<form #bankUrlForm name="bankUrlForm" action="{{bankTranactionModel.sendToBankUrl}}" method="post" target="_self" >
<input type="hidden" name="RefId" [ngModel]="bankTranactionModel.refId">
</form>
并从服务器获取 bankTranactionModel
数据
并正确填写数据、操作 url、refid、...
和代码隐藏
@ViewChild('bankUrlForm') bankPostMethod;
并调用提交
this.bankPostMethod.submit();
我收到错误
TypeError: this.bankPostMethod.submit is not a function
我也用过ngform
但是我得到了错误。
以及何时使用这个
@ViewChild('bankUrlForm') bankPostMethod: ElementRef<HTMLFormElement>;
重定向页面并显示错误
masspurchase:1 POST http://localhost:4200/purchase/masspurchase 404 (Not Found)
@ViewChild('bankUrlForm')
returns ElementRef
of HTMLFormElement
你的情况:
@ViewChild('bankUrlForm') bankPostMethod: ElementRef<HTMLFormElement>;
因此,为了访问本机 HTMLFormElement.submit() 方法,您需要编写:
this.bankPostMethod.nativeElement.submit();
我不得不这样做并且它起作用了也许在 typescript
上使用 javascript 是错误的
var form = document.createElement("form");
form.setAttribute("method",sendMethod);
form.setAttribute("action", bankUrl);
form.setAttribute("target", "_self");
var hiddenField = document.createElement("input");
hiddenField.setAttribute("name", "RefId");
hiddenField.setAttribute("value", refIdValue);
form.appendChild(hiddenField);
document.body.appendChild(form);
form.submit();
document.body.removeChild(form);
我在 angular
的 html 端创建了 post 方法<form #bankUrlForm name="bankUrlForm" action="{{bankTranactionModel.sendToBankUrl}}" method="post" target="_self" >
<input type="hidden" name="RefId" [ngModel]="bankTranactionModel.refId">
</form>
并从服务器获取 bankTranactionModel
数据
并正确填写数据、操作 url、refid、...
和代码隐藏
@ViewChild('bankUrlForm') bankPostMethod;
并调用提交
this.bankPostMethod.submit();
我收到错误
TypeError: this.bankPostMethod.submit is not a function
我也用过ngform
但是我得到了错误。
以及何时使用这个
@ViewChild('bankUrlForm') bankPostMethod: ElementRef<HTMLFormElement>;
重定向页面并显示错误
masspurchase:1 POST http://localhost:4200/purchase/masspurchase 404 (Not Found)
@ViewChild('bankUrlForm')
returns ElementRef
of HTMLFormElement
你的情况:
@ViewChild('bankUrlForm') bankPostMethod: ElementRef<HTMLFormElement>;
因此,为了访问本机 HTMLFormElement.submit() 方法,您需要编写:
this.bankPostMethod.nativeElement.submit();
我不得不这样做并且它起作用了也许在 typescript
上使用 javascript 是错误的var form = document.createElement("form");
form.setAttribute("method",sendMethod);
form.setAttribute("action", bankUrl);
form.setAttribute("target", "_self");
var hiddenField = document.createElement("input");
hiddenField.setAttribute("name", "RefId");
hiddenField.setAttribute("value", refIdValue);
form.appendChild(hiddenField);
document.body.appendChild(form);
form.submit();
document.body.removeChild(form);