Skip to content

Instantly share code, notes, and snippets.

@lorenzojkrl
Created May 22, 2022 12:54
Show Gist options
  • Save lorenzojkrl/cd45fa9f1d4e260f23c09d8edad198b3 to your computer and use it in GitHub Desktop.
Save lorenzojkrl/cd45fa9f1d4e260f23c09d8edad198b3 to your computer and use it in GitHub Desktop.
Angular 14 - typed forms
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