Recently started self-taught angularjs this front-end MVC framework, feeling that MVC is cool to implement in front of the wood has. Hahaha ...
First of all, I have a basic understanding of the front-end MVC (the first learning contact is relatively simple, understanding may be some not in place, but also ask you to correct the great God).
First, the M (model) layer of MVC, the data Model layer, is used to process the data information in the business and the state information in the storage business. When the data in the model changes, the updated data needs to be displayed in the view layer. In the framework of the traditional back-end implementation of MVC, it is usually the page submits a form or the AJAX request to the background action, and the action calls the Business Processing module (service) to change the data in the background model layer, and finally return the data to the view layer and refresh the page. However, in Angularjs, we can implement model in the front-end, and through the Angularjs two-way data binding, so that the model layer of data in real-time display in the view layer, all this allows us to the front end of the processing of data directly to the backstage, You can even refresh the page without having to. All, this can reduce a lot of code, greatly improving the development efficiency of Web applications.
Here is an example of the first angularjs I wrote:
Hello.html
<!DOCTYPE HTML><HTMLNg-app= "Hello"><Head> <title>Hello</title> <Scripttype= "Text/javascript"src= "Javascripts/angular.min.js"></Script> <Scripttype= "Text/javascript"src= "Javascripts/hello.js"></Script></Head><Body> <DivNg-controller= "Yourname"> <label>{{You.title}}:</label> <inputtype= "text"Ng-model= "You.name"placeholder= "Enter a Name Here"> <HR/> <H1>Hello,{{you.name}}</H1> <ButtonNg-click= "You.say ()">Say</Button> </Div></Body></HTML>
Hello.js
var mymodule = angular.module ("Hello", []) Mymodule.controller ("YourName", [' $scope ', function ($scope) { = { title:' Input your name ', name:' , say:function() { alert (this. name);}} ;} ]);
And I want to throw up the trough ... Angularjs's official website is on the mainland. WTF ...
Luluzero's Angularjs Learning path _angularjs Sample code