2015-10-25 42 views
8

La documentazione corrente di Angular2 non fornisce un esempio per l'utilizzo di @Input e @Output nella sintassi es5.Come dichiarare gli input su un componente in Angular 2 in ES5?

Sto cercando di ottenere un violino angular2 così bisogno di usare ES5

Questa è la versione 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; 
} 

risposta

12

Usa inputs e outputs immobili a Component annotazione. Vedi 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; 
    } 
    }); 
+1

Come implementarlo in HTML? Qualcosa del genere: asubanovsky

+0

Controllare Plunkr menzionato nella risposta. Dovresti usare ''. Nell'esempio viene usata la versione alfa di angular2 e lì dovresti usare "account-id" invece di "accountId' –

+0

Puoi mostrare un esempio del suo uso anche. Questo è così utile. –

Problemi correlati