Previous projects were all using jquery and original JavaScript, and a recent project needed to use a angularjs, Requirejs, and other relatively tidal framework. Here to write some blog, record their own learning process, although the name of the original, in fact, are referring to some of the online information, coupled with some of their own practice and understanding. No longer familiar with Angularjs, there is no estimate of high-quality articles, can only be regarded as learning notes and memos. The version used for the exercise is the latest stable version of 1.2.25.
The sample code is as follows:
<!doctype html>
Open this web page in a browser, enter it in the text box, and the interface will display automatically in real time. If you are using JavaScript or jquery to do such a small function, our group registers the listener event, gets the value of the text control, and then plugs the value into the Angularjs is much simpler and the code is more compact. Let's look at these 3 things in a nutshell: 1,Ng-app: It can be placed on any DOM node, representing the node and all its child nodes are within the angularjs management range; If you remove this tag, the Angularjs frame will not work.
<!doctype html>
This time we putNg-app put on the <div>, you can see the div inside the over to Angularjs to manage, or only part of the ANGULARJS Admin page can be added as needed the DOM node where the Ng-app resides.
2,Ng-model: This is the bidirectional binding feature of the ANGULARJS data. Easy to understand: Tell Angularjs This is a data model and you help me save it in memory. Modify the data on the interface, the data in memory will be changed automatically, and the interface display will be changed automatically if the variable value in memory is modified. This feature is obviously convenient to maintain the consistency of the data, avoiding the ability to add code to do this.
3. {{YourName}}: This is the expression syntax provided by the framework to display the values of the data model in memory. This is similar to Struts2 's <s:property>, <s:text>, which is used to display data. This is just angularjs definition of the syntax format, and the JSP page in the El expression, struts2 ognl very similar, is a kind of data acquisition mechanism.
(i) Hello World angularjs Primer Sticker