The difference between AngularJs 1.x and ANGULARJS2

Source: Internet
Author: User

AngularJS 2 Although still in the alpha phase, the main features and documentation have been released. Let me understand the difference between angular 1 and 2, and how the new design goals will be implemented.

1. From the mobile app development above analysis:

Angular 1.x focuses on web development , does not involve the mobile this aspect of content, fortunately later killed a way to bite Gold Ionic mobile app development framework, let angularjs1.x very good support for mobile development

Angular 2 target: Native mobile support –ios and Android

Angular 2 will have two layers, application layer and render layer. For example, a component can be decorated with a different @View decorator, which can take effect at run time depending on the operating environment.

As with React Native, Angular 2 supports:

One study, writing everywhere. This means that when you create a native app, you can reuse the knowledge you learned when you created your web app. Although there are always some differences.

2. provide support analysis from server-side rendering:

Support for server-side rendering is important for search engine optimization and user-perceived experience, and in a larger angular 1 application, even with a pre-defined cache module, we can clearly see the page loading process when the app starts to start.

At this point it seems that this part of the ANGUALR2 is not very clear, but this idea may be reflected in the following aspects:

Start start, and all components are bound

and rendering is not implemented

A page after the server is rendered and then sent to the client

Angular will parse it and then inject the parsed page into the DOM, which avoids the flicker effect.

3. From Dependency Injection analysis

In the world of angular 1, dependency injection is a technology leap forward in building multi-module applications, but in some extreme cases it is not possible to solve these problems without making some important changes.

Angular 1.x contains the object global pool

Angular 1 in one of the DI cases, there is only one object global pool per app. This means that if the primary route Loadsbackendservice we are directed to Route B, it is possible to defer loading other services specified to this route.

The problem is that we say we can delay loading a secondbackendservice, using a completely different implementation: This will rewrite the first one! There is currently no way to do the same name with two different implementations of two services, which prevents a secure way to implement lazy loading from Angular 1.

Angular 1.x multi-Dependency injection mechanism

In Angular 1, we can use different methods for injection in multiple places:

By location injection in the link method

Injected by name in a direct definition

In the Controller method through the name, and so on.

Angular 2 What will be done in the

In Angular 2, there is only one dependency injection mechanism: injection through a type in the constructor.

Constructor (Keyutils:keyboardutils) {
This.keyutils = keyutils;
}
});

In fact, if there is only one mechanism, then it will become easier to learn. At the same time, this dependency injector is similar to the hierarchical structure, at different levels of the component tree, it is possible to implement different implementations of the same type.

If a component does not have a dependency defined, it proxies to the upper-level injector to find the dependency, and then go up. This allows Angular 2 to provide native lazy loading as possible .

4. Analysis from the main objective

The difference between AngularJs 1.x and ANGULARJS2

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.