angularangular2-formsdynamicform

How get values as integer in formGroup.value in Angular2


I make a form using DynamicForm it work perfect but when try to get the values using form.value or form.getRawValue() all files are return like string, how I make to the number files as return as integer in the JSON file

Example

actually I get a JSON like this

{
  "name": "home",
  "age": "12"
}

but I need this:

{
  "name": "home",
  "age": 12
}

EDIT

The formControl constructor

const form = new FormGroup({
  name : new FormControl(undefined  || '', Validators.required),
  age  : new FormControl(undefined  || '')
}); 

Solution

  • try putting null into first param of FormControl