Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

angular

Angular2's current documentation doesn't provide an example for using @Input and @Output in es5 syntax.

I'm trying to get an angular2 fiddle up so need to use es5

This is the es2016 version

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;
}
like image 582
CheapSteaks Avatar asked Oct 25 '15 06:10

CheapSteaks


1 Answers

Use 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;
    }
  });
like image 81
alexpods Avatar answered Sep 18 '22 16:09

alexpods