years ... But since already exist, we might as well think in a reasonable direction, perhaps Ng's designers do not want to let the template become a simple view layer, is to enhance the HTML, let it have a little business capability. It seems to be able to think that way, OK, first deceive yourself ~V. Special NG-SRC and Ng-hrefBefore explaining the special requirements of these two instructions, you need to know about Ng's start-up and execution process, such as:1) The browser loads the static
Injector
Injector-a container that relies on injection
Module
Contains containers for various parts of the application, including controllers, services, filters, directives.
Services
Services-A separate view of business logic that can be reused
Template and ViewTake a look at the code first1 DivNg-app Ng-init= "qty=1;cost=2">2 b>Invoic
When creating Bindings, you can also choose not to specify the binding target. It is usually used for the Concrete classes or types that contain @ ImplementedBy and @ ProvidedBy (described later ). The purpose of Untargeted bindings is to notify Injector of a class type, so that Injector can prepare a dependency in advance. Untargetted Bindings does not include the to statement.
For example:
[Java] bind (
The special NG-SRC and ng-href of the seaBefore explaining the special two instructions, you need to understand the start and execution of Ng, as follows:1) The browser loads the static HTML file and parses it into DOM;2) Browser loading angular.js file;3) Angular Monitoring domcontentloaded event, monitoring to start;4) Angular look for Ng-app directive, determine the scope of action;5) Find the module defined in the app using the $injector service f
dependency injection is used, the dependency control of client classes is no longer located in these classes; instead, it is implemented in the injector. See the following code:
public static void main(String[] args) { UserFifoQueue fifoQueue = new UserFifoQueue(); fifoQueue.add(new User("user1")); fifoQueue.add(new User("user2")); fifoQueue.add(new User("user3")); UserProcessor userProcessor = new UserProcessor(fifoQueue); us
calculate the expression and insert the result into the DOM. We will see that the DOM can be updated in real time as the result of the expression operation changes.
AngularJS expression Angular expression is a code snippet similar to JavaScript. AngularJS expressions only run in AngularJS scope, rather than in the entire DOM.
Guide AngularJS applications
Using ngApp commands to automatically guide AngularJS applications is a simple method and is suitable for most cases. In advanced development,
Here ' s The calling order:App. Config ()App.run ()Directive ' s compile functions (if they is found in the DOM)App.controller ()Directive ' s link functions (again if found)Here's a simple demo where can watch each of the Execute (and experiment if you ' d like).From Angular ' s module docs:Run Blocks-get executed after the injector is created and be used to kickstart the application. Only instances and constants can is injected into run blocks. This
In angular, the Directive, Service, Filter, and Controller are given in a factory way, and the parameter name of the factory method corresponds to the Service that the factory method relies on. Such as:App.controller (' Wolrdctrl ', function ($scope, $http) {//...});functionprior to the above execution, Angular Injector generates an instance of an $scope instance and $http passes in the method. If you want to compress JS, then the parameter name may c
)
The context used to store the model. The model is placed in this context to be accessed by controllers, directives, and expressions, etc.
Expressions (expression)
Variables and functions in scope (scope) can be accessed through the template
Compiler (Compiler)
Used to compile the template and instantiate the directives (Directive) and expressions (expression) contained therein
Filters (Filter)
The value that is responsible for forma
First, the start-up phaseAs you all know, when a browser loads an HTML page, it parses the HMTL page into a DOM tree and loads each element node in the DOM tree one by one. We can think of Angularjs as a jquery-like JS Library, we introduce the set an event listener to listen to the browser domcontentloaded event. When angular hears this event, it launches the angular application. Ii. phase of initializationWhen angular starts, it looks for the Ng-app directive, initializes a series of necessar
Angular uses the Interceptor to uniformly process http requests and responses.
If you want to use htpp in angularjs to send requests to the backend, a token that is uniquely identified by the user wants to be placed in headers, that is, {headres: {'Token': 1 }}
The following js is introduced in index.html:
angular.module('app.factorys',[]) .factory('httpInterceptor',['$q','$injector','$localStorage',function ($q,$
interrupted by a previous request interceptor. It can be used to restore the request or sometimes to undo the configuration that was made before the request, such as closing the progress bar, activating the button and the input box, and so on.
To responseError intercept a response exception by implementing the method: sometimes our back-end calls fail. It is also possible that it was rejected by a request interceptor or was interrupted by a response interceptor. In this case, the response ex
layer, but if it happens that the same module is loaded two times the problem occurs.Angular 1.x multi-Dependency injection mechanismIn Angular 1, we can use different methods for injection in multiple places:By location injection in the link methodInjected by name in a direct definitionIn the Controller method through the name, and so on.Angular 2 What will be done in theIn Angular 2, there is only one dependency injection mechanism: injection through a type in the constructor.Constructor (Key
files, and merge index files
1), inject URLs
Org. Apache. nutch. Crawl. Injector
Inject and capture URLs. Because the web page needs to be captured by the crawling program of nutch, You need to specify a URL to locate a (or some) web page. On this basis, the web page captures the content according to the breadth traversal policy, based on the specified URL (which can be a URL set: URLs.
The specific format is
The specific form of the "crawldatum" cl
First, the start-up phaseAs you all know, when a browser loads an HTML page, it parses the HMTL page into a DOM tree and loads each element node in the DOM tree one by one. We can think of Angularjs as a jquery-like JS Library, we introduce the Ii. phase of initializationWhen angular starts, it looks for the ng-app instruction, initializes a series of necessary components (i.e. $injector, $compile service, and $rootscope), and then begins parsing the
equivalent to $. This makes it possible to use the familiar selector.
Methods of extending
Jqlite includes some additional methods to accommodate the ANGULARJS framework:
Controller (name)-Gets the control object corresponding to the element
Injector ()-Gets the injector object corresponding to the element
Scope ()-Gets the scope object corresponding to the element
Isolat
AngularJS is a popular front-end language in recent years, extending HTML through new attributes and expressions , overcoming The lack of HTML in building applications. Angular Declarative template powerful, with rich instructions, is a perfect front-end MVVM Framework, the realization of the data two-way binding, filter, Dependency injection, modularization, service and other functions. AngularJS Implementation of data bidirectional binding is manifested in interacting with the browser and i
the $apply method accessible. Only the model changes in the $apply method will be correctly angular statistically. For example, a directive listens for DOM events, such as Ng-click, which must evaluate an expression in the $apply method.
After the expression is evaluated, a $digest is executed $apply method. In the $digest phase, scope examines all $watch listening expressions, comparing the current value to the old value. The dirty check (dirty checking) is asynchronous. This means that an as
A module in ANGULAR2 refers to a class that is decorated with @ngmodule. @NgModule use a metadata object to tell angular how to compile and run the code. A module can contain components, directives, pipelines, and can declare their access rights public so that the components of the external module can access and use them.
module is used to organize the application, through the module mechanism external class library can be very convenient to extend the application, after Rc5, ANGULAR2 will many
container that the service needs to be injected, when the operation, the container will bring an instance to the service, complete the injection process.
Defines a Guice module file that tells the container how to inject.
import com.google.inject.Binder; import com.google.inject.Module; import com.google.inject.Scopes; public class MyModule implements Module ...{ public void configure(Binder binder) ...{ binder.bind(MyService.class).to(MyServiceImpl.class).in(Scopes.SINGLETON); // 这句代码的意思是说:运
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.