Data Binding

Angular 2 supports data binding, which can coordinate parts of a template with parts of a component. Binding markup in the template HTML tells Angular 2 how to connect both sides.

There are mainly four forms of data binding syntax and three directions:

  • To the DOM: interpolation, property binding
  • From the DOM: event binding
  • Both directions: two-way data binding

Two-way data binding, is just a combination of property binding and event binding.

For example, this two way binding

<input [(ngModel)]="name">

you can write like

<input [ngModel]="name" (ngModelChange)="name = $event">

We will talk those in following chapters when we meet them again.

results matching ""

    No results matching ""