what is the difference between using formControlName
inside brackets and without brackets? In the dynamic form tutorial formcontrolname
is used inside brackets
[formControlName]="dyncontrol.key"
but in other tutorials i have seen it without them
formControlName="name"
Here's from the Template Syntax documentation:
Remember the brackets
The brackets tell Angular to evaluate the template expression. If we forget the brackets, Angular treats the string as a constant and initializes the target property with that string. It does not evaluate the string!
Don't make the following mistake:
<!-- ERROR: HeroDetailComponent.hero expects a Hero object, not the string "currentHero" --> <hero-detail hero="currentHero"></hero-detail>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With