Typically the reason you see that in tutorials and what not is because 
getters are defined for the control.

On Friday, March 12, 2021 at 6:02:25 AM UTC-5 Todd Zmijewski wrote:

> god darnit....
>
> get control(): FormControl {
>   return this.form.get('control');
> 
> }
> On Friday, March 12, 2021 at 6:01:24 AM UTC-5 Todd Zmijewski wrote:
>
>> Do you have a getter for the control?
>>
>> control is not a property of the component. Either you need to create a 
>> getter or explicitly reference the control.
>>
>> view:
>>
>> form.get('control').touched && form.get('control').invalid
>>
>> or
>>
>> component class:
>>
>> get control(): FormControl {
>>   return form.get('control');
>> }
>>
>> On Friday, March 12, 2021 at 5:42:06 AM UTC-5 john.mb...@gmail.com wrote:
>>
>>> Hi,
>>>
>>> So, in my Angular reactive forms, I am binding my form control to my 
>>> component and in each component I have the following:
>>>
>>> ```
>>> public form: FormGroup = new FormGroup({
>>> control: new FormControl('', [Validators.required, Validators.max(1)])
>>> });
>>> ```
>>> I have added this into select dropdown in my HTML: 
>>>
>>> [ngClass]="{ 'is-invalid': control.touched && control.invalid }"
>>>
>>> I am not seeing is-invalid, am I doing something wrong?
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/angular/0ffa4c10-f52c-4edb-b4fd-9e49b7784923n%40googlegroups.com.

Reply via email to