Last active
June 27, 2022 11:59
-
-
Save wpflames/09ebeae48230886cbcdfe7fdf1f1585f to your computer and use it in GitHub Desktop.
Template driven 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'; | |
| @Component({ | |
| selector: 'contact-form', | |
| templateUrl: './contact-form.component.html', | |
| styleUrls: ['./contact-form.component.scss'] | |
| }) | |
| export class ContactFormComponent { | |
| log(x) { console.log(x); } | |
| } |
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
| <h2>Leave a comment</h2> | |
| <form> | |
| <div class="form-group"> | |
| <label for="firstName">First Name</label> | |
| <input | |
| ngModel | |
| name="firstName" | |
| #firstName="ngModel" | |
| (change)="log(firstName)" | |
| type="text" | |
| id="firstName" | |
| required | |
| class="form-control"> | |
| </div> | |
| <div class="form-group"> | |
| <label for="comment">Comment</label> | |
| <textarea name="comment" id="comment" cols="30" rows="10" class="form-control"></textarea> | |
| </div> | |
| <button class="btn btn-dark">Submit</button> | |
| </form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment