search
HomeWeb Front-endJS TutorialDetailed explanation of the differences between AngularJS, Angular 2, and Angular4


Literal difference

(1) The Angular 1 we often say refers to AngularJS; the name has been changed since Angular 2. No longer with JS, just pure Angular;
(2) There is also an incredible version change: jumping directly from Angular 2 to Angular 4, why is Angular 3 missing?

Differences in architecture

Angular 1 is a typical MVC architecture (Model - View - Controller), and its architecture is as shown in the figure:

MVC 架构示意图

Compared with Angular 1's MVC architecture, Angular 2 is a typical component-based architecture. In this way, it is similar to React.js structure. As shown in the figure below:
Angular 2  架构

Why is Angular 2 launched in a hurry?

It stands to reason that Angular 1. x version is already powerful enough, so why rush to launch Angular 2? This is driven by the needs of mobile apps. According to conventional thinking: Angular 2 should be an upgraded version of Angular 1.x. In fact, it is not the case. Angular 2 is completely different from Angular 1.x, and the most basic syntax is different. Angular 1.x is a JavaScript-based framework, while Angular 2 is a TypeScript-based framework.

So, when you decide to learn Angular, you must decide whether to learn Angular 1 or Angular 2. So which version is better to learn? It’s hard to say, it depends on the needs of the project. If you are simply learning, of course the higher the version the better, keep up with the times!

Why is Angular 3 missing?

When the Angular team was developing Angular 3, there was a problem with the router module. After much struggle, they decided to give up Angular 3 and go directly to Angular 4

What are the benefits of Angular 2?

Compared with Angular 1.x, Angular 2 is smaller in size. Why is this done? To put it bluntly, one word - fast; If it is only used for PC-side WEB development, Angular 1 .x is enough to cope with it; if it is used for mobile app, it is slightly stretched in terms of user experience!

What’s so good about Angular 4?

Angular 4 is an upgraded version of Angular 2. That is to say, since Angular 2, their versions have been in the same vein. They are upgraded versions, not pushed to a new version. Angular 4 is faster than Angular 2.
So, from Angular 1.x to Angular 2, and then to Angular 4, the route is to be faster.

The code written in Angular 1 cannot be used in Angular 2. Why is this?

Angular 1 code is written based on JavaScript, code example:

var angular1 = angular
       .module('uiroute', ['ui.router']);
angular1.controller('CarController', function ($scope) {
    $scope.CarList = ['Audi', 'BMW', 'Bugatti', 'Jaguar'];
});

Angular 2 code is written based on TypeScript. The difference between TypeScript and JavaScript is huge. TypeScript is a superset of JavaScript. Look at a piece of Angular 2 code:

import { platformBrowserDynamic } from "@angular/platform-browser-dynamic";
import { AppModule } from "./app.module";
platformBrowserDynamic().bootstrapModule(AppModule);  
import { NgModule } from "@angular/core";  
import { BrowserModule } from "@angular/platform-browser";  
import { AppComponent } from "../app/app.component";  
@NgModule({  
    imports: [BrowserModule],  
    declarations: [AppComponent],  
    bootstrap: [AppComponent]  
})  
export class AppModule { }  
import { Component } from '@angular/core'  @Component({  
    selector: 'app-loader',  
    template: `  
<p>   
<p>  
 <h4 id="Welcome-nbsp-to-nbsp-Angular-nbsp-with-nbsp-ASP-NET-nbsp-Core-nbsp-and-nbsp-Visual-nbsp-Studio-nbsp">Welcome to Angular with ASP.NET Core and Visual Studio 2017</h4></p></p>`  
})  
export class AppComponent{}

If you are not familiar with TypeScript syntax, the above code will be incomprehensible! Since the difference is so big, it is predictably difficult to upgrade Angular 1 to Angular 2!

It seems that the difference between Angular 1 and 2 is not a difference in framework, but that their syntax is completely different. One uses JavaScript and the other uses TypeScript. So why is Angular 4 an upgraded version of Angular 2? The answer is simple, because both 4 and 2 use TypeScript usage!

Code reuse method

In Angular 1, the most commonly used one is $scope which has been removed in Angular 2 and 4. In the new version, directive and controller are more recommended. By splitting the component component, code reuse is achieved.

Support for Mobile app

The original design intention of Angular 1 is to implement responsive web pages and two-way data binding web applications. From the perspective of the concept of Html5, Angular 1 is considered a very A good front-end framework that supports H5. If we have higher expectations for Angular, we hope that Angular can support mobile apps well and achieve the native user experience of the APP. This is the shortcoming of Angular 1. In view of the words, Angular 2 and later Angular 4 were launched.

Next, let’s focus on the architecture of Angular 2

Angular 2 architecture

It can be said that Angular 2 is an architecture for mobile apps, in order to achieve the native effect of the APP , Angular 2 uniquely introduces NativeScript technology.

Angular 2 的APP 效果

How to solve the cross-platform problem of APP

Angular 2 solves the cross-platform problem of mobile app. The so-called cross-platform refers to the Web written with Angular 2 To achieve the same native user experience on iOS and Android, you only need to write a set of code.

Summary

If you are new to Angular development, it is recommended to start with Angular 2, which is relatively simpler; not to mention that Angular 4 is still being continuously updated. After the version is stable, you can then move to Angular 4 Let’s go!

related suggestion:

Detailed explanation of common pipeline examples in Angular4

Write a complete Angular4 FormText component method

Detailed explanation of actual project construction of angular4


The above is the detailed content of Detailed explanation of the differences between AngularJS, Angular 2, and Angular4. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Python vs. JavaScript: Which Language Should You Learn?Python vs. JavaScript: Which Language Should You Learn?May 03, 2025 am 12:10 AM

Choosing Python or JavaScript should be based on career development, learning curve and ecosystem: 1) Career development: Python is suitable for data science and back-end development, while JavaScript is suitable for front-end and full-stack development. 2) Learning curve: Python syntax is concise and suitable for beginners; JavaScript syntax is flexible. 3) Ecosystem: Python has rich scientific computing libraries, and JavaScript has a powerful front-end framework.

JavaScript Frameworks: Powering Modern Web DevelopmentJavaScript Frameworks: Powering Modern Web DevelopmentMay 02, 2025 am 12:04 AM

The power of the JavaScript framework lies in simplifying development, improving user experience and application performance. When choosing a framework, consider: 1. Project size and complexity, 2. Team experience, 3. Ecosystem and community support.

The Relationship Between JavaScript, C  , and BrowsersThe Relationship Between JavaScript, C , and BrowsersMay 01, 2025 am 12:06 AM

Introduction I know you may find it strange, what exactly does JavaScript, C and browser have to do? They seem to be unrelated, but in fact, they play a very important role in modern web development. Today we will discuss the close connection between these three. Through this article, you will learn how JavaScript runs in the browser, the role of C in the browser engine, and how they work together to drive rendering and interaction of web pages. We all know the relationship between JavaScript and browser. JavaScript is the core language of front-end development. It runs directly in the browser, making web pages vivid and interesting. Have you ever wondered why JavaScr

Node.js Streams with TypeScriptNode.js Streams with TypeScriptApr 30, 2025 am 08:22 AM

Node.js excels at efficient I/O, largely thanks to streams. Streams process data incrementally, avoiding memory overload—ideal for large files, network tasks, and real-time applications. Combining streams with TypeScript's type safety creates a powe

Python vs. JavaScript: Performance and Efficiency ConsiderationsPython vs. JavaScript: Performance and Efficiency ConsiderationsApr 30, 2025 am 12:08 AM

The differences in performance and efficiency between Python and JavaScript are mainly reflected in: 1) As an interpreted language, Python runs slowly but has high development efficiency and is suitable for rapid prototype development; 2) JavaScript is limited to single thread in the browser, but multi-threading and asynchronous I/O can be used to improve performance in Node.js, and both have advantages in actual projects.

The Origins of JavaScript: Exploring Its Implementation LanguageThe Origins of JavaScript: Exploring Its Implementation LanguageApr 29, 2025 am 12:51 AM

JavaScript originated in 1995 and was created by Brandon Ike, and realized the language into C. 1.C language provides high performance and system-level programming capabilities for JavaScript. 2. JavaScript's memory management and performance optimization rely on C language. 3. The cross-platform feature of C language helps JavaScript run efficiently on different operating systems.

Behind the Scenes: What Language Powers JavaScript?Behind the Scenes: What Language Powers JavaScript?Apr 28, 2025 am 12:01 AM

JavaScript runs in browsers and Node.js environments and relies on the JavaScript engine to parse and execute code. 1) Generate abstract syntax tree (AST) in the parsing stage; 2) convert AST into bytecode or machine code in the compilation stage; 3) execute the compiled code in the execution stage.

The Future of Python and JavaScript: Trends and PredictionsThe Future of Python and JavaScript: Trends and PredictionsApr 27, 2025 am 12:21 AM

The future trends of Python and JavaScript include: 1. Python will consolidate its position in the fields of scientific computing and AI, 2. JavaScript will promote the development of web technology, 3. Cross-platform development will become a hot topic, and 4. Performance optimization will be the focus. Both will continue to expand application scenarios in their respective fields and make more breakthroughs in performance.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Atom editor mac version download

Atom editor mac version download

The most popular open source editor