Skip to content

Instantly share code, notes, and snippets.

@badbabykosh
Last active August 25, 2017 04:01
Embed
What would you like to do?
Angular2 vs Angular4

What is the diff between Angular2 and Angular4?

Well there is no path breaking change that means Angular 4 is not a complete rewrite of Angular 2 .

Google has adapted SEMVER (Semantic versioning) approach for it’s Angular Framework.

  • Why not Angular 3?

Due to misalignment of router package version . As @angular/router was using v3.3 already , so they switch to Angular 4 Finally .

  • What has Changed?

Angular team has laid emphasis on making angular apps more faster,compact .

Under the Hood Changes

New changes reduce the size of the generated code for your components by around 60% in most cases.

The more complex your templates are, the higher the savings.

Faster Compilation

Better Bug fixes Alert.

Some changes in Imports/Syntax

  • Animations being pulled out of @angular/core so as to remove the extra code being imported into our production bundle .Though you can easliy add animation by importing {BrowserAnimationsModule} from @angular/platform-browser/animations into NgModule.
  • Renderer 2 in place of Renderer from same ‘@angular/core’.
  • ngIf/else : Now you can use else clause as well .
  • For email validation in Angular forms
  1. Earlier Angular 2 : pattern = “[a-z0-9!#$%&'+/=?^_`{|}~.-]+@a-z0-9?(.a-z0-9?”
  2. Now Angular 4: Now just put email as an attribute to input field where you want to have email id .Here email is an angular directive not to confuse with the type=”email” which is just an HTML DOM type property .
  • TypeScript 2.1 and 2.2 compatibility: Finally We can use typescript 2.1 or more earlier only upto typescript 1.8 was supported.

So that’ s all has changed .

NOTE :

Since the arrival of Angular 2 and Angular 4.The complete framework is referred as Angular not AngularJs as the latter one refers to the Angular1.x framework.

Source : Angular 4.0.0 Now Available

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment