How to use angular 1.3.4 and angular 2 together

Mohit Bumb picture Mohit Bumb · May 24, 2016 · Viewed 9.9k times · Source

I have already an application which is build on angular 1.3.4 and I want to change it to angular 2 but module wise.

lets say I've 5 modules on my page I want to migrate one module to angular 2 and other should work as it is like before with 1.3 so slowly slowly I can convert but till that it should not stop working.

I include both angular 2 and angular 1.3.4 libraries and it saying angular is not defined in console

Answer

C. Molendijk picture C. Molendijk · May 24, 2016

Please read this blog: http://angularjs.blogspot.nl/2015/08/angular-1-and-angular-2-coexistence.html

It explains how to run it together and how to finally upgrade to Angular 2.

The important thing of this link is:

For this to work, four things need to interoperate between Angular 1 and Angular 2:

  • Dependency injection
  • Component nesting Transclusion
  • Change detection

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.

So you need ng-upgrade. See more information about that here: https://angular.io/docs/ts/latest/guide/upgrade.html