(1) Hello World, angularjshello
Previous projects used JQuery and original javascript. Recently, a project used AngularJS, RequireJS, and other popular frameworks. Here I write some blogs to record my learning process. Although the original name is used, it is actually based on some online materials, and some of my own practices and understandings. Before getting familiar with AngularJS, it is estimated that there are no high-quality articles, which can only be used as study notes and memos. The exercise version is the latest stable version 1.2.25.
The sample code is as follows:
<!doctype html>Open the webpage in a browser and enter it in the text box. The page is automatically displayed in real time. If javascript or jquery is used to complete such a small function, we need to register the listening event, obtain the value of the text control, and then add the value to
1. ng-app: It can be placed on any dom node, representing that the node and all its subnodes are within the management scope of AngularJS. If this flag is removed, it is found that the AngularJS framework does not work.
<!doctype html>This time, we put ng-app on <div>. We can see that
2. ng-model: This is the bidirectional binding feature of AngularJS data. Easy to understand: Tell AngularJS that this is a data model. You can save it to the memory for me. The data is modified on the interface, and the data in the memory is automatically modified. The variable value in the memory is also changed on the Interface display. This feature is obviously very convenient and can maintain data consistency, so that we do not need to add code to complete this function.
3. {yourName}: This is the expression syntax provided by the Framework. It can display the value of the data model in the memory. This is similar to <s: property> and <s: text> of struts2. It is used to display data. This is just the syntax format defined by AngularJS. It is similar to the EL expression on the JSP page and the OGNL of struts2. It is a data acquisition mechanism.
C # as follows: Hello World. How can I call the following code to copy the code in a cs file during window creation?
This is a console application, not a windows application!
Region ~~
Using System;
// A "Hello World! "Program in C #
Namespace HelloWorld
{
Class Hello
{
Public static string SayHello ()
{
Return "Hello World! ";
}
}
}
Then write in your form
This. label1.Text = HelloWorld. Hello. SayHello ();
Establish an AngularJS Environment
Pay attention to the following key areas,
1. Add ng-app
2. Introduce angularjs.
See angularjs.org/here for details.
<! Doctype html>