Forked from azanebrain/angular-form-value-vs-getrawvalue.ts
Created
July 23, 2018 14:52
-
-
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/
This file contains hidden or 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