Angular 2: Introduction

By: 
 | 
November 17, 2016
Aug 11, 2022
 | 
Read time: 
5
 min
Angular 2: Introduction

Angular (or AngularJS) is a frontend web-framework created by Google, containing everything needed to stand up a complex, yet easy to use, front-end web application.

If you’ve ever used AngularJS, then you’ve likely already experienced some of its drawbacks. However, Angular recently had a major release, “Angular 2”, which addresses many of these drawbacks (and ended up being a complete re-write of AngularJS). So what makes Angular 2 better than AngularJS?

To keep things short and sweet, we'll go over the three most notable changes...

TypeScript

One major change between Angular 1 and 2 is the introduction of Microsoft’s TypeScript language in place of the standard JavaScript. While standard JavaScript can still be used, Angular 2 is written in TypeScript and as such comes highly recommended.

TypeScript must be compiled down to regular JavaScript before it can be used in a browser (Chrome is considering making it standard, but that's another story entirely...), in similar fashion to technologies like LESS (CSS), SASS (CSS), and PugJS (HTML)

It allows for many improvements over standard JavaScript applications. Instead of having to wait for browsers to become compliant with the latest JavaScript standards, TypeScript can be used and then compiled down to any version of JavaScript that is required by an application's user base.

There are way too many features of TypeScript to go into in this short introduction, so we'll save the good stuff for later articles...

Speed

A common complaint with AngularJS was its speed. Due to this, Angular 2 was made to be far faster than it's counterpart in nearly every aspect, almost to the point of being as fast as even the likes of React. Quite an impressive feat, considering Angular is a fully-featured framework as opposed to the more simplified view library that is React.

Components

AngularJS 1.5 introduced Components. While useful for AngularJS, one of the main reasons behind the introduction of Components in AngularJS was to prepare developers for migrating their applications over to Angular 2. If you're familiar with AngularJS, Components can basically (though not entirely) be summed up as shorthand Directives.

Components allow chunks of code to be shared between different sections within an application, or even a different application entirely, with ease. They've technically existed (as stated above) since AngularJS, but the Angular team really buckled down and based Angular 2 development around making completely Component-based applications. Prior to Angular 2, they were more of a feature to be used, as opposed to being the basis for the entire application.