Developers can now mix AngularJS 1.x with AngularJS 2.x

Aug 26, 2015 09:38 GMT  ·  By

With the release date of AngularJS 2 getting nearer and nearer, Google released a set of recommendations on how to slowly upgrade applications written in AngularJS 1.x to using AngularJS 2.x code.

While AngularJS is an open source library to which everyone can contribute, most of the people involved with its development are Google employees, so we can safely call it a Google project without being wrong.

When the news about AngularJS 2 first came out, along with the information that 2.x will be incompatible with the 1.x Angular branch, developers went crazy and started preaching about an upcoming Apocalypse.

Not blind to the ill sentiment this announcement infused in the Angular community, Google soon corrected course and announced that there would be some 1.x intermediary releases (1.5.x) specifically dealing with smoothing out the transition to the 2.x branch.

That announcement, which came with the launch of AngularJS 1.4.0, didn't help calm developers down, so the Angular team apparently went to work and yesterday released a simple guide, along with a special AngularJS library that can help developers mix AngularJS 1.x and 2.x code in the same applications.

Google: We're enabling mixing of Angular 1 and Angular 2 in the same application

"To make all this possible, we're building a library named ng-upgrade. You'll include ng-upgrade and Angular 2 in your existing Angular 1 app, and you'll be able to mix and match at will," said Brad Green, engineering director at Google, the person in charge of the AngularJS project.

Besides mixing Angular 1 and Angular 2 in the same application, developers will also be able to combine Angular 1 and Angular 2 components in the same view, let Angular 1 and Angular 2 inject services across frameworks, and use data binding across both versions of the framework.

The AngularJS team also provided access to their Angular 1 to Angular 2 Upgrade Strategy on Google Docs, and is also working on future documentation which includes a detailed migration guide with working code samples, the AngularJS 2.x FAQ, and how developers can map their AngularJS 1.x knowledge to AngularJS 2.x code.

Developer reaction to this news was a little warmer than the ones from the past. Here's just one of the positive comments programmers left on Hacker News: "Since Angular 2 was announced, I had the feeling that I picked the wrong framework for our product with Angular 1, and was feeling regrets about that choice towards my team, to have blocked them with a framework without future. Knowing that we'll be able to slowly move our app to Angular 2, one feature at a time, is certainly the best news I've had in a while."