Skip to content

Instantly share code, notes, and snippets.

@nirlanka
Last active August 5, 2018 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nirlanka/fb5fa321625f66fcc1508c9fb49f897f to your computer and use it in GitHub Desktop.
Save nirlanka/fb5fa321625f66fcc1508c9fb49f897f to your computer and use it in GitHub Desktop.
<form [formGroup]="addFriendForm" (ngSubmit)="onSubmit()">
<input type="text" formControlName="name">
<input type="text" formControlName="email">
<button type="submit"
[disabled]="!f.valid">Submit!</button>
</form>
// Component
public addFriendForm: FormGroup;
constructor(formBuilder: FormBuilder) {
this.addFriendForm = formBuilder.group({
name: [user.name, Validators.required],
email: [user.email, Validators.required]
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment