Four core features of AngularJS:
1. MVC:
Model: Data Model layer
View: Views layer, all you can see belongs to the view layer
Controller: Business logic and Control logic
Benefits: Clear responsibilities, Code modularity
Why there is no MVC in 23 design patterns:MVC is actually the evolution of the other three classic design patterns: The Observer Pattern (Observer) (pub/sub), the Strategy mode (strategy) and the combo mode (Composite), It is a combination of three modes !
ng-app>ng-controller= "Test"> <p>{{Monica.aha}}</p> </div> <script src= "js/angular-1.3.0.js" ></script> <script src= "Helloangular_mvc.js "></script></body>
function Test ($scope) { = { ' Monica is My Name ' };}
In this example, Ng-app is equivalent to Main in Java
<div ng-controller= "Test" > Controllers Controller
<p>{{monica.aha}}</p> is view
function Test ($scope) { $scope. Monica = { aha: ' Monica is My Name ' };
As model
The function of {{}} in the P element is to get the data
2. Modular
Create the Angular module object first, then call the Controller method
<!DOCTYPE HTML><HTMLNg-app= "a"> <Head> <MetaCharSet= "Utf-8"> </Head> <Body> <DivNg-controller= "B"> <P>{{Greeting.Text}}</P> </Div> <DivNg-controller= "C"> <P>{{Greeting.Text}}</P> </Div> </Body> <Scriptsrc= "Js/angular-1.3.0.js"></Script> <Scriptsrc= "Helloangular_modle.js"></Script></HTML>
var mymodule = Angular.module ("A", []), Mymodule.controller ("B", [' $scope ', function ($scope) { = { ' Hello ' }; }]); Mymodule.controller ("C", [' $scope ', function ($scope) { = { ' Hello AngularJS ' }; }]);
3. Instruction System
<!DOCTYPE HTML><HTMLLang= "en"Ng-app= "Dir"><Head> <MetaCharSet= "UTF-8"> <title>Document</title> <style>. Test{Color:#eee; } </style></Head><Body> <Hello></Hello> <Scriptsrc= "Js/angular-1.3.0.js"></Script> <Scriptsrc= "Helloangular_dir.js"></Script></Body></HTML>
var myDir = angular.module (' Dir ', []); Mydir.directive (function() { Return { ' E ', ' <div class= ' test ' >hi monica</div> ', true }});
4. Bidirectional data binding
<!DOCTYPE HTML><HTMLNg-app><Head> <MetaCharSet= "UTF-8"> <title>Document</title></Head><Body> <Div> <inputNg-model= "Greeting.Text"> <P>{{Greeting.Text}}, AngularJS</P> </Div> <Scriptsrc= "Js/angular-1.3.0.js"></Script></Body></HTML>
Three x Study questions:
1. Why other front-end frameworks do not support bidirectional data binding
2. If you want to implement two-way data binding, how to implement
3. What are the potential problems with the bidirectional data binding mechanism?
AngularJS. 1