在括号内使用 formControlName
和不在括号内有什么区别?在动态表单教程中 formcontrolname
被用在方括号内
[formControlName]="dyncontrol.key"
但在其他教程中我看到没有它们
formControlName="name"
最佳答案
这里来自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>
关于angular - 带或不带括号的 formControlName?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39496787/