Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add form with validation and messages #12

Merged
merged 4 commits into from
Jun 16, 2018
Merged

Add form with validation and messages #12

merged 4 commits into from
Jun 16, 2018

Conversation

brunolm
Copy link
Owner

@brunolm brunolm commented Jun 16, 2018

ng g c heroes/hero-edit

Add ReactiveFormsModule from @angular/forms into heroes.module.ts.

Bind (ngSubmit) on form. Link form to FormGroup object.

<form (ngSubmit)="submit()" [formGroup]="heroForm">

Use constructor(private formBuilder: FormBuilder) { to build all controls of your form.

this.formBuilder.group({
  fieldName: this.formBuilder.control('default value', [validator(s)]);
});

@brunolm brunolm self-assigned this Jun 16, 2018
@brunolm brunolm merged commit 0684e5f into master Jun 16, 2018
@brunolm brunolm deleted the feature/hero-form branch June 16, 2018 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant