How to set value to FormBuilder object in angular 2 Typescript
You can achievie that by invoking setValue
method on your FormControl
object:
(<FormControl> this.AMform.controls['Name']).setValue("new value");
or:
this.Name.setValue("new value");
Use patchValue method of your FormGroup object.
onAccntChange(event: Event) {
this.AMform.patchValue({yourControl: studentModelValue})
}
Using setValue
you need to specify all the FormControls:
this.AMform.setValue({'Name':'val1', 'Address':'val2'})
Using patchValue
you can specify just the one you need:
this.AMform.patchValue({'Name':'val1'})
Here you can read a little bit more.