2
2
@name Data Binding
3
3
@description
4
4
5
- Data-binding in Angular web apps is the automatic synchronization of data between the model and view
5
+ Data-binding in Angular apps is the automatic synchronization of data between the model and view
6
6
components. The way that Angular implements data-binding lets you treat the model as the
7
7
single-source-of-truth in your application. The view is a projection of the model at all times.
8
8
When the model changes, the view reflects the change, and vice versa.
@@ -11,20 +11,19 @@ When the model changes, the view reflects the change, and vice versa.
11
11
12
12
<img class="right" src="img/One_Way_Data_Binding.png"/>
13
13
Most templating systems bind data in only one direction: they merge template and model components
14
- together into a view, as illustrated in the diagram . After the merge occurs, changes to the model
14
+ together into a view. After the merge occurs, changes to the model
15
15
or related sections of the view are NOT automatically reflected in the view. Worse, any changes
16
16
that the user makes to the view are not reflected in the model. This means that the developer has
17
17
to write code that constantly syncs the view with the model and the model with the view.
18
18
19
19
## Data Binding in Angular Templates
20
20
21
21
<img class="right" src="img/Two_Way_Data_Binding.png"/>
22
- The way Angular templates works is different, as illustrated in the diagram. They are different
23
- because first the template (which is the uncompiled HTML along with any additional markup or
24
- directives) is compiled on the browser, and second, the compilation step produces a live view. We
25
- say live because any changes to the view are immediately reflected in the model, and any changes in
26
- the model are propagated to the view. This makes the model always the single-source-of-truth for
27
- the application state, greatly simplifying the programming model for the developer. You can think of
22
+ Angular templates work differently. First the template (which is the uncompiled HTML along with
23
+ any additional markup or directives) is compiled on the browser. The compilation step produces a
24
+ live view. Any changes to the view are immediately reflected in the model, and any changes in
25
+ the model are propagated to the view. The model is the single-source-of-truth for the application
26
+ state, greatly simplifying the programming model for the developer. You can think of
28
27
the view as simply an instant projection of your model.
29
28
30
29
Because the view is just a projection of the model, the controller is completely separated from the
0 commit comments