如何在ES5中声明Angular 2中组件的输入?
Angular2当前的文档没有提供在es5语法中使用如何在ES5中声明Angular 2中组件的输入?,angular,Angular,Angular2当前的文档没有提供在es5语法中使用@Input和@Output的示例 我正在试着让angular2拉琴,所以需要使用es5 这是es2016版本 class BankAccount { @Input() bankName: string; @Input('account-id') id: string; // this property is not bound, and won't be automatically updated by Angular nor
@Input
和@Output
的示例
我正在试着让angular2拉琴,所以需要使用es5
这是es2016版本
class BankAccount {
@Input() bankName: string;
@Input('account-id') id: string;
// this property is not bound, and won't be automatically updated by Angular
normalizedBankName: string;
}
在组件注释中使用和属性。看
var BankAccount=ng
.组成部分({
选择器:'银行账户',
模板:{{bankName}}{{id}},
投入:[
“银行名称”,
'id:accountId'
]
})
.类({
构造函数:函数(){
this.bankName=null;
this.id=null;
}
});
如何在HTML中实现它?类似这样:检查答案中提到的Plunkr。您应该使用
。示例中使用了angular2的alpha版本,您应该使用account id
而不是accountId
。您也可以展示一下它的用法。这非常有用。我还想知道如何将数据从普通HTML传递到组件中。答案中提到的Plunkr从父组件调用
组件。