A simple AngularJs example is as follows:
<!DOCTYPE HTML><HTMLNg-app><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" /><Scriptsrc= "Angular.min.js"></Script></Head><Body><DivNg-controller= "Firstcontroller"><P><inputtype= "text"Ng-model= "Name" /><P><P>{{Name}}</P></Div><Script>functionFirstcontroller ($scope) {$scope. Name= "Suliang";}</Script></Body></HTML>
The above is one of the most typical angularJs MVC Architecture Example model layers that can controller modify the model data content in a layer through a layer, and model the results of the data modification will be directly fed back to the view layer.
angularJsYou can use the angular.module method to set up the module, the above example uses a modular rewrite as follows:
<!DOCTYPE HTML><HTMLNg-app= "MYAPP"><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" /><Scriptsrc= "Angular.min.js"></Script></Head><Body><DivNg-controller= "Firstcontroller"><P><inputtype= "text"Ng-model= "Name" /><P><P>{{Name}}</P></Div><Script>varM1=Angular.module ("myApp",[]); //Defining ModulesM1.controller ("Firstcontroller",function($scope) {//Defining the Controller$scope. Name= "Suliang";})</Script></Body></HTML>
Using the above method can encapsulate a module, but on-line resource compression will be $scope replaced, $scope is dependent on the injected variable, the name can not be modified, so we can create the controller when the following:
M1.controller ("Firstcontroller", ["$scope",function($scope) { = "Suliang";}])
Modularity in the Angularjs