如何在 ES5 中的 Angular 2 中的组件上声明输入?
How to declare Inputs on a component in Angular 2 in ES5?
Angular2 的当前文档没有提供在 es5 语法中使用 @Input
和 @Output
的示例。
我正在尝试使用 angular2 fiddle,所以需要使用 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;
}
使用inputs
and outputs
properties in Component
annotation. See this plunker.
var BankAccount = ng
.Component({
selector: 'bank-account',
template: '<b>{{ bankName }}<b><span>{{ id }}',
inputs: [
'bankName',
'id: accountId'
]
})
.Class({
constructor: function() {
this.bankName = null;
this.id = null;
}
});
Angular2 的当前文档没有提供在 es5 语法中使用 @Input
和 @Output
的示例。
我正在尝试使用 angular2 fiddle,所以需要使用 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;
}
使用inputs
and outputs
properties in Component
annotation. See this plunker.
var BankAccount = ng
.Component({
selector: 'bank-account',
template: '<b>{{ bankName }}<b><span>{{ id }}',
inputs: [
'bankName',
'id: accountId'
]
})
.Class({
constructor: function() {
this.bankName = null;
this.id = null;
}
});