官术网_书友最值得收藏!

Data Binding

Data Binding is one of the core responsibilities of developers when writing code to bind data to the user interface and update changing data according to user interactions with the user interface. Angular has reduced the burden of writing large amounts of code to handle Data Binding:

Angular handles Data Binding by coordinating with templates and components. The templates provide instructions to Angular on how and what to bind. There are two types of binding in Angular: globally One-way Data Binding and Two-way Data Binding. One-way Data Binding deals with either binding data from the component to the DOM or from the DOM to the component. Two-way Data Binding deals with both sides of communication, that is, the component to the DOM and the DOM to the component.

<div>Title: {{book.title}}<br/> 
  Enter Author Name: <input [(ngModel)]="book.author"> 
</div> 

Here, book.title wrapped in double curly braces deals with One-way Data Binding. The value of book title, if available in the component instance, will be displayed in the view. book.author, assigned to the ngModel property of the input element, deals with Two-way Data Binding. If the component instance has a value in the author property, then it will be assigned to the input elements, and if the value is changed by the user in the input control, then the updated value will be available in the component instance.

We will learn in detail about Data Binding in Chapter 8, Template and Data Binding Syntax.

主站蜘蛛池模板: 延吉市| 敦煌市| 五常市| 石阡县| 登封市| 巴南区| 盖州市| 治县。| 安丘市| 三明市| 南漳县| 肇庆市| 象州县| 汝城县| 三原县| 唐山市| 元江| 且末县| 大理市| 卢氏县| 灌云县| 无锡市| 遂平县| 塔城市| 黎平县| 雷波县| 韶关市| 榆树市| 嘉义县| 平江县| 涡阳县| 墨竹工卡县| 类乌齐县| 马公市| 治县。| 时尚| 广州市| 兴业县| 墨江| 嵊泗县| 北川|