AngularJs Real Combat-mu class network

Source: Internet
Author: User

https://www.codecademy.com/en/courses/learn-angularjs/lessons/your-first-app/exercises/ Your-first-app-hello-angularjs-i?action=resume
-MCV is only a means, the ultimate goal is modularity and multiplexing

How MVC Controller is implemented
    • Do not use inherited, universal controllers, to use server errors correctly
Note points in the process of controller use
    • Do not attempt to re-use the controller, a director is generally responsible for a small piece of view
    • Do not manipulate the DOM in the controller, which is not the responsibility of the Controllers
    • Do not format the data in the controller, NG has a very useful form control
    • Do not do data filtering operations in controller, NG has $filter service
    • In general, controllersdo not call each other , and the interaction between them is done through events
AngularJS MVC is implemented using scopes ($scope).
    • Scope Up Lookup: $emit ()
    • Scope Down Lookup: $broadcast ()
    • Each angular application has only one $rootscope object (typically located on Ng-app)
    • $scope is a tree structure, parallel to the Dom tag
    • properties and methods on scope for child \ (Scope object inherits parent \)
    • $scope can propagate events, like DOM events, which can be up or down.
    • $scope is not only the basis of MVC, but also the basis for implementing bidirectional data binding later.
    • Can be debugged with angular.element ($). Scope ()
AngularJS everything is starting with the module
    • App.js portal, modules, routing functions and dependency injection
      • Dependency Injection and page introduction of JS Sequence Association is not big
AngularJS Dual Binding
    • Double binding: Modifying a view can also modify the values above the model
    • Ng-bind is used in the home page, you can hide {{ng variable}}, no template variable is displayed
    • Using a double-bound scenario is the form most commonly used, resetting some values, modifying the class
    • Benefits without directly manipulating the DOM, you can modify the model directly.
    • Ng-class: Enhanced Expression
    • Ng-show: By judging whether the content is displayed
    • Ng-animate:: Animation effect
Three problems with AngularJS routing routing to solve Ajax
    1. Ajax requests do not leave a history record
    2. Users cannot save bookmarks directly via URL to the page specified in the app, and link to a friend? )
    3. Ajax for SEO poor >ui-router than angular comes with the use of the route
Fundamentals of front-end routing
    1. Hash #, can be compatible with legacy browsers
    2. The new history API in H5
    3. The core of the route is to define "state" for the application
    4. Using a routing mechanism affects the overall encoding of your app (requires a pre-defined state)
    5. Consider compatibility, gracefully downgrade (old hash, new history)

AngularJs Real Combat-mu class network

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.