繁体   English   中英

如何在ES5中的Angular 2中声明组件的输入?

[英]How to declare Inputs on a component in Angular 2 in ES5?

Angular2的当前文档没有提供在es5语法中使用@Input@Output的示例。

我试图让一个有角度的小提琴,所以需要使用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;
}

Component注释中使用inputsoutputs属性。 看到这个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;
    }
  });

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM