Created
May 22, 2022 12:54
-
-
Save lorenzojkrl/cd45fa9f1d4e260f23c09d8edad198b3 to your computer and use it in GitHub Desktop.
Angular 14 - typed forms
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
import { Component } from '@angular/core'; | |
import { FormControl, FormGroup } from '@angular/forms'; | |
@Component({ | |
selector: 'profile', | |
templateUrl: './profile.component.html', | |
styleUrls: ['./profile.component.css'], | |
}) | |
export class ProfileComponent { | |
profileForm = new FormGroup({ | |
firstName: new FormControl('Mark'), | |
lastName: new FormControl('Doe'), | |
}); | |
populate() { | |
// TS error: Argument of type '10' is not assignable to parameter of type 'string | null'. | |
this.profileForm.controls.firstName.setValue(10); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment