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
- Ajax requests do not leave a history record
- Users cannot save bookmarks directly via URL to the page specified in the app, and link to a friend? )
- Ajax for SEO poor >ui-router than angular comes with the use of the route
Fundamentals of front-end routing
- Hash #, can be compatible with legacy browsers
- The new history API in H5
- The core of the route is to define "state" for the application
- Using a routing mechanism affects the overall encoding of your app (requires a pre-defined state)
- Consider compatibility, gracefully downgrade (old hash, new history)
AngularJs Real Combat-mu class network