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

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.

主站蜘蛛池模板: 镇坪县| 漯河市| 加查县| 铁岭市| 香港 | 鄯善县| 阜阳市| 赤峰市| 渭南市| 安西县| 明光市| 元阳县| 广西| 宁陵县| 博客| 宜都市| 三河市| 连平县| 怀安县| 若尔盖县| 游戏| 丹江口市| 开阳县| 桃园市| 伊金霍洛旗| 黑水县| 临沧市| 新巴尔虎右旗| 确山县| 都江堰市| 哈巴河县| 赣榆县| 海门市| 句容市| 成安县| 芷江| 泾源县| 酒泉市| 台前县| 无为县| 陈巴尔虎旗|