javascript / beginner
Snippet
Reactive Form Controls
FormControl is used in Reactive Forms to manage the state, value, and validation of a specific input field.
snippet.js
1
2
3
4
5
search = new FormControl('');clearSearch() {this.search.setValue('');}
angular
Breakdown
1
search = new FormControl('');
Creates a new instance to track the input value, initialized as an empty string.
2
this.search.setValue('');
Programmatically updates the value of the control, which reflects instantly in the UI.