What’s new in Angular 2.0? Why it’s rewritten – addressing few confusions
First official announcement of Angular 2.0 was made at the ng-conference in October, 2014. There the team Angular said, they are not going to release a new major update of AngularJs, but an entirely rewritten framework with no backward compatibility.
This step is taken not only to improve the current angular in terms of features and performance, but also because they are more interested in future web; i.e. web components and ES6; which is a phenomenal thing about this beautiful framework.
This article is devided into two sections. One contains the specialities of AngularJs 2.0; whereas in the second part I tried to answer few very common questions related to the new framework.
What’s new in AngularJs 2.0
Though Angular 2.0 is enriched with hell lot of features, but here I will describe only those which is really extraordinary and forced the team to rewrite the framework.
Change in ideology
A future ready framework
As things have been moved to MVC to web components, routers are also redesigned. The child router will convert each component of the application into a smaller application by providing it with its own router. It will help encapsulate entire feature sets of an application.
No require.js (in future)
Previously in case of large Angular apps, for modular code structure I had to use require.js; but as Angular 2.0 by default supports ES6, things are auto modular. No need for a third party library. However currently as browsers are not supporting ES6 properly, you will need system.js
Much better DI
The DI in Angular has been improved a lot in 2.0, where they introduced child injectors, instance scope etc. More on this can be found in the upcoming tutorials of Void Canvas.
Many of us may have faced the necessity where you wanted to provide the controller or directive at runtime. Don’t worry, you are all set to fall in love with 2.0.
As Angular 2.0 templates are using ES6 module spec, so template compiling will be asynchronous from now on.
A service called diary.js has been introduced to Angular 2.0, which will help you to log the application’s performance. This can be very useful to find the flaws of your own code and make the app more performant.
Confusions regarding AngularJs 2.0
Can I use ES5?
Yes you can. But things will be more ugly I guess. Moreover Angular 2.0 is future, so it’s better to use ES6 like syntaxes through typescript.
Is TypeScript mandatory?
Is there no controller?
If we look at a lot of different apps today we would probably see the same thing as the Angular team has seen in the 1600+ projects used internally at Google: controllers aren’t really needed. But yeah, directives still have the controllers.
Is $scope and jqLite really removed?
No $scope and jqLite; that’s for sure.
How to upgrade my app to 2.0?
“It’s really hard for us to build a bridge to a city that doesn’t exist yet.” – Brad Green, Engineering Director, Angular core team. Right now there is no specific way, but we can see ofter angular 2 is fully created.