Skip to content

Instantly share code, notes, and snippets.

@azanebrain
Last active July 23, 2018 14:53
Show Gist options
  • Save azanebrain/be36cbd57f4fcc6d915d6e93b3861db8 to your computer and use it in GitHub Desktop.
Save azanebrain/be36cbd57f4fcc6d915d6e93b3861db8 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