You can supply an optional name to use in templates when the component is instantiated, that maps to the name of the bound property. By default, the original name of the bound property is used for input binding. 你可以提供一个可选的仅供模板中使用的名字,在组件实例化时,会把这个名字映射到可绑定属性上。 默认情况下,输入绑定的名字就是这个可绑定属性的原始名称。 The following example creates a component with two input properties, one of which is given a special binding name. 下面的例子创建了一个带有两个输入属性的组件,其中一个还指定了绑定名。 @Component({ selector: 'bank-account', template: ` Bank Name: {{bankName}} Account Id: {{id}} ` }) class BankAccount { // This property is bound using its original name. @Input() bankName: string; // this property value is bound to a different property name // when this component is instantiated in a template. @Input('account-id') id: string; // this property is not bound, and is not automatically updated by Angular normalizedBankName: string; } @Component({ selector: 'app', template: ` <bank-account bankName="RBC" account-id="4747"></bank-account> ` }) class App {} |