gpt4 book ai didi

angular - 带或不带括号的 formControlName?

转载 作者:太空狗 更新时间:2023-10-29 17:02:47 25 4
gpt4 key购买 nike

在括号内使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com