我有一个传统的后端服务器,它将表单数据作为请求参数处理 . 我们将angular2放在前端 . 我想提交angular2表单,以便所有字段都作为请求参数,以便不必更改传统后端 . 要做到这一点,我有:
<form ngNoForm action="http://localhost/config/api/v1/angular/submit" target="_blank" method="POST">
但我也想在提交按钮上使用angular2表单验证:
<form #f="ngForm" ngNoForm action="http://localhost/config/api/v1/angular/submit" target="_blank" method="POST">
<button type="submit" [disabled]="!f.form.valid" class="small round">Submit</button>
然而,这不起作用 - angular2抱怨在声明ngNoForm时#f =“ngForm” .
有没有办法像往常一样进行angular2表格验证,还提交表格作为常规请求参数?
1 回答
使用纯JS强制提交,这对我有用: