Angular 4 Released
Last week, Google released the newest version of their Angular framework, Angular 4.0. The biggest changes seem to be around creating smaller builds and faster code. Our Solutions Group has several Angular 2 applications in production that we have already upgraded to Angular 4, and I am happy to report that the upgrade was smooth in each case.
If you are wondering if upgrading to Angular 4 is a good idea, I have put together a list of potential questions to help you decide.
What’s different about Angular 4?
As I mentioned, it is smaller and faster. But there are a variety of other changes you may find useful
- if…else syntax in HTML templates
- Separate animation module
- Angular Universal is now part of @angular/core
- Supports the latest version of Typescript
Why should I upgrade?
In most cases, your Angular 2 code should run fine with Angular 4, so there is little risk in upgrading your projects. As far as the amount of time it takes, each project we have upgraded took less than an hour to complete. The basic steps to upgrading are as follows:
- Update all of the @angular/xxx references in your package.json to use version ^4.0.0
- Delete the node_modules folder
- Run npm install (or yarn if you are using that)
- Test your app
Another reason to upgrade is that if you are using the angular-cli (which also hit version 1.0 last week), new cli-generated projects are using Angular 4.
Why did the version jump from 2 to 4?
At some point during the development of Angular 2, the router moved to version 3. Moving to Angular 4 was the solution to bring the router and the rest of the libraries back to the same major version.
Every project is different and you have to weigh the risks against the benefits, but I think for most projects it will make sense to upgrade to Angular 4.