Two-way binding

Last, but not least, is two-way binding, which is essentially a combination of event and property bindings. Not every property can be used with two-way binding, since it requires a certain convention and is used mostly in forms.

Two-way binding is used to bind an element's property to component data, in addition to updating the component data when the target element's property changes. You use two-way binding by surrounding a property with both parentheses and square brackets:

<input [(ngModel)]="myNameField" />

In the preceding example, ngModel is set with a two-way binding; thus, the input value is bound to the component's nameInput field and vice versa, so nameInput should change when the input value changes.

ngModel is a built-in directive, as part of Angular's forms module, that supports two-way binding with common form elements. This is covered in Chapter 11, Implementing Routing and Forms, where you learn implementing forms in Angular. 
There is much more to template syntax, binding, and directives. You can read more about it at https://angular.io/guide/template-syntax.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.60.158