Take the example:
model.ts
export interface Item{
name: string;
age: string
}
component.ts
form: FormGroup
constructor(private fb: FormBuilder){}
onInit(){
this.form = fb.group({
name: [''],
age: ['']
})
}
exampleFn(){
const signature: Item = Object.assign({},this.form.value);
console.log(typeof(signature.age)); // <=== HERE
// output number
}
html
<form [formGroup]="form">
<input formControlName="name" type="text"/>
<input formControlName="age" type="number"/>
</form>
Why the value is not string ? In model was defined with string, although the input type is number ,because i wanna show it frindly, but i need in a string , and i dont wanna convert individualy (thinking in a scenerio that have a bunch of itens typed in a model).
thanks
STACKBLITZ EXAMPLE