2017-02-16 3 views
0

私は2番めに新しいです。自分のコンポーネントの変数をビューの入力から更新しようとしています。私の入力を変数にバインドする方法がわからないのですか?おかげ角2のデータバインディング

+0

ここは私の見解です。 – Gary

+1

http://stackoverflow.com/questions/31623879/angular-2-two-way-binding-using-ng-model-is-not-working –

+1

https://angular.io/docs/ts/latest/cookbook/component-communication.html –

答えて

1

私は最も簡単な方法は、あなたのコンポーネントに続いて

<input type="text" [(ngModel)]="yourVariable" /> 

ngModel

を使用することだと思う、あなたはより多くの情報については、変数「yourVariable」

import { Component } from '@angular/core'; 

@Component({ 
    selector: 'my-cool-app', 
    templateUrl: './something.html', 
    styleUrls: ['./something.css'] 
}) 
export class TimeSliderComponent { 
    private yourVariable: string; 

    constructor() { } 
} 

を作ることができ、チェックアウト: をhttps://angular.io/docs/ts/latest/api/forms/index/NgModel-directive.html

関連する問題