Blog

What's New in AngularJS 2

angular logo

According to the latest news concerning IT frameworks, we face big changes. We can find out two main reasons for this process. First of all the newest version of Javascript – ECMAScript 6 came out bringing a huge number of innovations. It explains why AngularJS has to be readjusted to support new features.

The second reason for major changes is the architecture of the framework. Originally, AngularJS wasn’t made to solve the tasks that are assigned to it today. It is reflected in the fact that AngularJS API now resembles a kind of a maze. Of course it does not reduce the capacity of the framework, however, it makes it’ s learning more complicated.

Before starting to talk about the future of AngularJS let me remind you about its current version.

Angular 1.3 is the best version of AngularJS that is available at this moment. It is one of the strongest and most deliberate frameworks for now. More than 1600 projects were made using AngularJS in Google. They’ve made a lot of investments in the current version, so in any case Google will support it. Indeed, it’ s time to refactor the whole framework and that’s how AngularJS 2 appeared. The framework is becoming more and more documented and now it’s easier to understand how it works.

Perhaps you think why AngularJS is needed at all. Why do we have to jump to 2.0 immediately and make multiply key changes? Is it worth it?

Originally AngularJS was made more than 5 years ago. Basically it was not intended for developers. It was more than a tool aimed at web designers who need to create an HTML form rapidly. Over time there have been made some changes based on different requirements, and developers, once they took a tool, began to create more and more complicated applications. AngularJS 1.x team worked a lot on the changes caters the needs of modern web applications. However, there is a number of restrictions affecting the possible improvements. Some of these limitations are associated with the performance and they are the result of the data binding model and infrastructure templates. To solve these problems, a completely new approach is needed.

Over the past 5 years, since the release of AngularJS, the Internet has changed dramatically. For example, 5 years ago it was possible to create a decent cross-browser site without the help of jQuery. However, today's browsers don’ t only make various changes to the DOM, but often these changes are relevant for frameworks.

For AngularJS to be on the same page with our modern Internet situation, AngularJS’s fundamental change is necessary. In fact, without AngularJS changes, AngularJS risks to become out of date in a year. And that's why AngularJS team creates a new version of AngularJS as a response to the challenges of time.

As a result we have a complete rethinking of the framework architecture. TypeScript has become one of the tools to work with AngularJS. TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. There are certain advantages of it: the identification of errors at an early stage before launching the browser and modular design. TypeScript is originally written for enterprise solutions when it is necessary to support a large, extensive code base. Nowadays all code examples of AngularJS 2 use the TypeScript syntax on the official website.

So what does it all mean for us? Nothing special! You just need to start learning AngularJS 2 and Typescript. :) All the enhancements are being made in this direction, so we have no other choice.

But let's be honest... AngularJS is not the easiest stuff to learn. But when you start you think: “Yep, that's fine. It's really as easy as ABC!!!” Then you begin to create your application and say, “Damn it!! ?? I don’t understand!" I‘ve heard this story thousand times. There is even a comic graph which illustrates it.

my feelings about angular

Most of the difficulties stem from the original design of the framework. Originally, there was no custom directives. For its implementation hardcode was written. And later, the directives appeared in the API. Initially, there was no controller, then...well, in general, take a look at the graph.

One of the most important things that will be removed within AngularJS 2.0 is: $ scope. However, despite the fact that the $scope is removed, some of features will remain. These capabilities will be moved and improved by becoming a part of the framework design. You may be overtaken by the $scope removal, but new design will simplify things within AngularJS and for developers. In general, all those things will not only solve the internal needs of AngularJS, but also open up new opportunities for you.

One of the really missing opportunities of Angular 1.x was dynamic code loading. It was very difficult or even impossible to add a new directive or controllers on the fly. It just was not supported. In Angular 2.0 we create some things from scratch remembering about asynchrony. And compiling a template is an asynchronous process.

The functionality of AngularJS 2 is very different from the previous version, this is due to 2 main factors: the update to the next version of JS (ECMAScript 6), and complete processing of language in accordance with the new standards of web development.

All this has its pros and cons. However, since the pros clearly outweigh the cons and the choice has already been made, we have to learn it. Moreover, no one doubts the possibility of Google to create development tools of high quality.