@Input 属性是否有使用 Angular 括号绑定符号的约定?
Is there a convention for using Angular brackets binding notation for @Input properties?
将 纯字符串值 绑定到 Angular
中组件的 @Input
属性 可以通过以下两种方式之一完成:
<my-component inputProperty="my-property-value"></my-component>
或:
<my-component [inputProperty]="'my-property-value'"></my-component>
其中一个通常比另一个更受欢迎吗? (有例外吗?)
是否有关于此的一般约定?
这是否在任何 Angular 风格指南中得到解决(在 official style guide 中找不到任何内容)。
来自 Angular 文档中的 One-time string initialization:
You should omit the brackets when all of the following are true:
- The target property accepts a string value.
- The string is a fixed value that you can put directly into the template.
- This initial value never changes.
将 纯字符串值 绑定到 Angular
中组件的 @Input
属性 可以通过以下两种方式之一完成:
<my-component inputProperty="my-property-value"></my-component>
或:
<my-component [inputProperty]="'my-property-value'"></my-component>
其中一个通常比另一个更受欢迎吗? (有例外吗?)
是否有关于此的一般约定?
这是否在任何 Angular 风格指南中得到解决(在 official style guide 中找不到任何内容)。
来自 Angular 文档中的 One-time string initialization:
You should omit the brackets when all of the following are true:
- The target property accepts a string value.
- The string is a fixed value that you can put directly into the template.
- This initial value never changes.