Last active
April 23, 2022 08:27
-
-
Save lorenzojkrl/8b8de13f3205859a651521b7c4dee8bc to your computer and use it in GitHub Desktop.
Angular Template-driven form using ngForm
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
<div> | |
<form (ngSubmit)="onSubmit(f)" #f="ngForm"> | |
<div> | |
<label for="name">Name</label> | |
<input type="text" id="name" name="name" [(ngModel)]="name" required /> | |
</div> | |
<div> | |
<label for="email">Email</label> | |
<input type="email" id="email" name="email" [(ngModel)]="email" /> | |
</div> | |
<div> | |
<label for="age">Age</label> | |
<input type="number" id="age" name="age" [(ngModel)]="age" /> | |
</div> | |
<div> | |
<label for="preference">Preference</label> | |
<select | |
id="preference" | |
name="preference" | |
[(ngModel)]="preference" | |
required | |
> | |
<option *ngFor="let pref of preferences" [value]="pref"> | |
{{ pref }} | |
</option> | |
</select> | |
</div> | |
<button type="submit">Submit</button> | |
</form> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment