Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use angular 1.3.4 and angular 2 together [duplicate]

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

like image 988
Mohit Bumb Avatar asked May 24 '16 07:05

Mohit Bumb


People also ask

Can you mix AngularJS and Angular?

With it you can mix and match AngularJS and Angular components in the same application and have them interoperate seamlessly. That means you don't have to do the upgrade work all at once, since there is a natural coexistence between the two frameworks during the transition period.

Can I run AngularJS and Angular side by side?

Dual Booting. During the process of migration you will run both AngularJS and Angular in the same application, at the same time. This concept is known as dual booting, and in this lecture we will see how we can get both the legacy and modern Angular frameworks to co-exist and work together within the same application.

What is the replacement of the controller and scope in Angular 2?

The controllers and $scope in Angular 1 have been replaced with “Components” in Angular 2. Hence we can say that it is a component-based framework, which uses zone.


1 Answers

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

like image 127
C. Molendijk Avatar answered Oct 18 '22 21:10

C. Molendijk