Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ackuser/a849bae22b429ab48a691cb01cd97b7a to your computer and use it in GitHub Desktop.

Select an option

Save ackuser/a849bae22b429ab48a691cb01cd97b7a to your computer and use it in GitHub Desktop.
From.value will not show disabled controls so use getRawValue() ~ http://azanebrain.github.io/news/angular-snafoo-form-value-vs-getrawvalues/
public myForm: FormGroup
constructor(private formBuilder: FormBuilder) { }
ngOnInit() {
this.myForm = this.formBuilder.group({
enabledControl: ['hello'],
disabledControl: [{
value: 'world',
disabled: true
}],
})
console.log(this.myForm.value)
/*
Outputs:
{
enabledControl: 'hello'
}
*/
console.log(this.myForm.getRawValue())
/*
Outputs:
{
enabledControl: 'hello',
disabledControl: 'world'
}
*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment