May 2018
Intermediate to advanced
512 pages
11h 3m
English
FormControl is highly customizable. It allows you to set a default initial value, add validators, or listen to changes on blur, change, and submit events, as follows:
examplenew FormControl('Bethesda', { updateOn: 'submit' })
We won't be initializing the FormControl with a value, but we need to implement a validator to disallow one character inputs:
src/app/city-search/city-search.component.tsimport { FormControl, Validators } from '@angular/forms'
src/app/city-search/city-search.component.tssearch = new FormControl('', [Validators.minLength(2)])
Read now
Unlock full access