1.AngularJS bidirectional data binding (bi-directional)
<!DOCTYPE HTML><HTMLNg-app> <Head> <Scriptsrc= "Http://code.angularjs.org/angular-1.0.1.min.js"></Script> </Head> <Body>Your Name:<inputtype= "text"Ng-model= "Yourname"placeholder= "World"> <HR>Hello {{Yourname | | | ' World '}}! </Body></HTML>
- Text input directives
<input ng-model="yourname" />
are bound to a named yourname
model variable.
- The double curly brace tag
yourname
adds the model variable to the greeting language book.
- You do not need to register an event listener or add an event handler for the app!
- Now try typing the name in the input box, and the name you type will be immediately updated to appear in the greeting. This is the concept of ANGULARJS bidirectional data binding. Any changes to the input box are immediately reflected in the model variable (One Direction), and any changes to the model variable are immediately reflected in the greeting text (the other side).
Analysis of 2.AngularJS applications
Describes the three components of the ANGULARJS application and explains how they map to the model-view-Controller design pattern:
Templates (Templates)
Templates are files written in HTML and CSS that show the view of your app. You can add new elements and attribute tags to HTML as instructions for the Angularjs compiler. The ANGULARJS compiler is fully extensible, which means that you can build your own HTML markup in HTML with ANGULARJS!
Application logic and Behavior (Behavior)
Application logic and behavior are controllers that are defined with JavaScript. Unlike standard AJAX applications, ANGULARJS does not require additional listeners or DOM controllers because they are built into the ANGULARJS.
Model data
Models are derived from the properties of Angularjs scope objects. The data in the model is probably a JavaScript object, an array, or a primitive type, which is not important, and it is important that they belong to the Angularjs scope object.
ANGULARJS maintains a bidirectional synchronization of the data model and the view interface UI through scopes. Once the model state changes, ANGULARJS is immediately refreshed and reflected in the view interface, and vice versa.
Angularjs Quick Start