<分区>
This示例显示了如何在子组件上使用 @Input() 注释。我的问题是你如何在根组件上使用它?例如,如果您修改上面链接上的代码:
@Component({
selector: 'app',
template: `
<bank-account bank-name="RBC" account-id="4747"></bank-account>
`,
directives: [BankAccount]
})
class App {
@Input() something: string;
}
bootstrap(App);
在 html 中:
<app something="Test"></app>
上面的例子从不更新 App 组件的something属性。