Angularjs Study Notes (Mu-class web)

Source: Internet
Author: User

1. Caution Points during controller use

    1. Do not attempt to re-use the controller, a director is generally responsible for a small piece of view
    2. Do not manipulate the DOM in the controller, which is not the responsibility of the controllers. Encapsulated in instructions.
    3. Do not format the data in the controller, NG has a very useful form control
    4. Do not do data filtering operations in controller, NG has $filter service
    5. In general, controllers do not call each other , and interactions between controller are---by events > this is strongly coupled

2.

<HTMLNg-app>    <Div>        <inputNg-model= "Greeting.Text"/>        <P>{{Greeting.Text}}, Angular</P>    </Div>    ....    <Scriptsrc= "Js/angular-1.3.0.js"></Script><HTML>

The value in the P tag is changed as input in input.

After starting, you will find the instructions in Ng-app. When Ng-model is found, the Greeting.Text data model is generated, which mounts the scope root so that all {{Greeting.Text}} can get its value

3. ANGULARJS MVC is implemented with the help of $scope

The scope is also hierarchical, and if no value is found in the inner scope, it will look up, similar to the prototype found in JS

4. About $scope

    1. $scope is a pojo (Plain old JavaScript Object)
    2. $scope provides some tool methods $watch ()/$apply ()
    3. $scope is the execution environment (or scope) of an expression
    4. $scope is a tree structure, parallel to the DOM tag
    5. The child $scope object inherits the properties and methods on the parent $scope
    6. Each angular application has only one root $scope object (typically located on Ng-app)
    7. $scope can propagate events, like DOM events, which can be down or up
    8. $scope is not only the basis of MVC, but also the basis for implementing bidirectional data binding later.
    9. Can be debugged with angular.element ($). Scope ()
    10. $scope life cycle: Creation->watcher Registration->model mutation->mutation observation->scope Destruction

Angularjs Study Notes (Mu-class web)

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.