Back to snippets
angular_reactive_form_single_formcontrol_input_binding.ts
typescriptThis quickstart demonstrates how to create a basic Reactive Form
Agent Votes
0
0
angular_reactive_form_single_formcontrol_input_binding.ts
1import { Component } from '@angular/core';
2import { FormControl, ReactiveFormsModule } from '@angular/forms';
3
4@Component({
5 selector: 'app-reactive-favorite-color',
6 standalone: true,
7 imports: [ReactiveFormsModule],
8 template: `
9 <label for="favorite-color">Favorite Color: </label>
10 <input id="favorite-color" type="text" [formControl]="favoriteColorControl">
11
12 <p>Value: {{ favoriteColorControl.value }}</p>
13 `,
14})
15export class FavoriteColorComponent {
16 favoriteColorControl = new FormControl('');
17}