Last active
July 23, 2018 14:53
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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