Say I have a form:-
searchForm = new FormGroup({
SearchBox = new FormControl<string>('', {nonNullable: true});
)}
And I try to do this:-
this.Query = this.searchForm.SearchBox.value;
The type of the Query property is a string, I get the error.
"Type 'string | undefined' is not assignable to type 'string'".
I can use the ! operator to make it work like so.
this.Query = this.searchForm.SearchBox.value!;
But is this the best way to tell it that the form control won't be undefined? Is there a better way to do this rather than slapping ! everywhere I want to assign the value of a form control to a property in the component?