AngularJS. 1

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.