Mekong
  1. Home
  2. Blog
  3. Hong Ngu, Border Crossing
Hong Ngu, Border Crossing

Hong Ngu, Border Crossing

by Mekong Princess


10/09/2018

Angular 4 or angular is a TypeScript-based open-source front-end web application platform led by the Angular Team at Google. Angular is a complete rewrite from the same team that built AngularJS. But let me tell you that Angular is completely different from AngularJS. Let us understand the differences between Angular and AngularJS:

  • The architecture of an Angular application is different from AngularJS. The main building blocks for Angular are modules, components, templates, metadata, data binding, directives, services and dependency injection. We will be looking at it in a while.
  • Angular was a complete rewrite of AngularJS.
  • Angular does not have a concept of “scope” or controllers instead, it uses a hierarchy of components as its main architectural concept.
  • Angular has a simpler expression syntax, focusing on “[ ]” for property binding, and “( )” for event binding
  • Mobile development – Desktop development is much easier when mobile performance issues are handled first. Thus, Angular first handles mobile development.
  • Modularity – Angular follows modularity. Similar functionalities are kept together in same modules. This gives Angular a lighter & faster core.

Now, let us talk about Angular 4. Angular community has introduced some significant changes to angular 4 and therefore, the major version number has been changed from 2 to 4 (skipping 3). The reason behind directly jumping to Angular 4 and skipping the version 3 was that the router package was in version 3.x, so instead of putting everything to 3.0 and the router to 4.0, the team chose to upgrade the versions of all the ng - modules to 4.0.

Let me tell you one more important news that the angular community has decided for some timely based releases occurring in three different phases:

  • Angular patches will be released every week
  • Few minor releases will be followed by major release
  • At last, there will be a major release every 6 months.

Before moving ahead, you may checkout this video on changes in Angular 4 that will help you to know about all the changes in 30 minutes:

 

Now let me point out the major changes for you that has been introduced in Angular 4 :

  • TypeScript 2.1+ Required: TypeScript 2.1 and 2.2 have brought really nice features you should check out. Angular 4 now supports them (and you will soon be able to activate the new strictNullChecks TypeScript option for example).
  • ModuleID Removed: They have added a new SystemJS plugin which dynamically converts "component-relative" paths in templateUrl and styleUrls to "absolute paths" for you.
  • Ahead of Time Compilation - View Engine: As you may know, in AoT mode, Angular compiles your templates during the build, and generates JS code whereas in case of Just in Time mode, this compilation is done at runtime. Now, AoT has several advantages, like you will get to know that your templates is incorrect at build time instead of having to wait at runtime, and the application starts faster (as the code generation is already done). The downside of AoT that people were facing was that the generated JS is generally bigger than the uncompiled HTML templates. So, in the vast majority of applications, the package is in fact bigger with AoT. The team worked quite hard to implement a new View Engine, that produces less code when you use the Ahead of Time compilation. The results are quite impressive on large apps, while still conserving the same performances. To give you a few numbers, on two medium apps we have, the bundle sizes went:
    • From 499KB to 187KB (68Kb to 34Kb after gzip)
    • From 192KB to 82KB (27Kb to 16Kb after gzip)
  • Animations: They have segregated animation package from @angular/core as a separate and dedication package. Therefore, if you don’t use animations, this extra code will not end up in your production bundles.
  • Template is now ng-template: The template tag is now deprecated: you should use the ng-template tag instead. It still works though. Now Angular has its own template tag: ng-template. You will have a warning if you use the deprecated template somewhere when you update to Angular 4, so it will be easy to spot them.