#14

Referencing Angular controls with dot notation

2019-08-23

TAGS: angular

Sometimes when referencing a specific control in an Angular 2+ FormControl, VSCode will claim that it can't find controls on personalForm in your template.

Here's an easy fix to appease the IDE Gods:

- [errors]="myForm.controls.firstName.errors ? myForm.controls.firstName.errors : []"
+ [errors]="myForm['controls'].firstName.errors ? myForm['controls'].firstName.errors : []"