Sun*_*era 8 typescript-typings angular formgroups
我提交表单组的价值是
{
"name": "Sunil",
"age": "23"
}
Run Code Online (Sandbox Code Playgroud)
我想要的是
{
"name": "Sunil",
"age": 23
}
Run Code Online (Sandbox Code Playgroud)
我的表单组在我的 .ts 文件中如下
myForm : FormGroup;
this.myForm = this._formbuilder.group({
name: [''],
age: [null]
});
Run Code Online (Sandbox Code Playgroud)
小智 11
在发送之前转换它。
const value = { ...this.myForm.value, age: +this.myForm.value.age };
Run Code Online (Sandbox Code Playgroud)
或者您可以使用数字类型的输入。
<input type="number" formControlName="age">
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13391 次 |
| 最近记录: |