AngularJS uses dirty checking in the $ scope variable to implement bidirectional data binding. Unlike the setter and getter dynamic facilities in the two-way binding of Ember. js data, the dirty check allows AngularJS to monitor variables that exist or do not exist. This time, we will detail angular's two-way data binding.
1. Simple example
This example has already been shown in section 1.
The result is that the content entered in the input box is changed accordingly. This enables two-way data binding.
II. use of value expressions and ng-bind
Let's look at another example. click here. in the first example in the text, {greeting. text }}and {text} are a value expression, but if you refresh the page, you will find such a problem, that is, sometimes "{greeting. text }}{ {text} ", how can we solve this problem?
The ng-bind command is used to bind a data expression.
For example
{{greeting.text}} {{text}}
Changed:
"";
After this correction, the page will be refreshed without any undesired strings.
However, using commands is always less efficient than using expressions directly, so we have summarized a common rule: in general, index uses ng-bind, the format of '{{}}' is used in subsequent templates.
III. typical scenario of bidirectional binding-form
Let's take a look at the content of form.html: