Created
July 2, 2017 09:52
-
-
Save Armenvardanyan95/2c5e0f5c0294d193b413af6d841fe7b9 to your computer and use it in GitHub Desktop.
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
| @Component({ | |
| selector: 'app-some-component-with-form', | |
| template: ` | |
| <div [formGroup]="form"> | |
| <div class="form-control"> | |
| <label>First Name</label> | |
| <input type="text" formControlName="firstName" /> | |
| </div> | |
| <div class="form-control"> | |
| <label>Last Name</label> | |
| <input type="text" formControlName="lastName" /> | |
| </div> | |
| <div class="form-control"> | |
| <label>Age</label> | |
| <input type="text" formControlName="age" /> | |
| </div> | |
| </div> | |
| ` | |
| }) | |
| export class SomeComponentWithForm { | |
| public form: FormGroup; | |
| constructor(private formBuilder: FormBuilder){ | |
| this.form = formBuilder.group({ | |
| firstName: ['', Validators.required], | |
| lastName: ['', Validators.required], | |
| age: ['', Validators.max(120)], | |
| }) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment