VladosJS
VladosJS

Reputation: 538

Using angular 2 components in angular 1 app without upgrade plugin

Currently we have old project developed using lineman-angular-templat, angular 1.5 and ES5

We need to add new features and i want to add them as angular 2 components. We have not time and money for creating new application with Angular 2.

The goad is to use angular 1 and ui-routing for navigation to new pages and insert into new pages angular 2 components.

Is it possible to do it without using upgrade plugin and downgrading angular 2 components to angular 1 directives?

Is it possible to have angular 1 and augular 2 components running together?

I really want to use benefits of angular 2 change detection mechanism etc

Upvotes: 2

Views: 1581

Answers (1)

meriton
meriton

Reputation: 70584

The angular docs write:

One of the keys to a successful upgrade is to do it incrementally, by running the two frameworks side by side in the same application, and porting Angular 1 components to Angular 2 one by one. This makes it possible to upgrade even large and complex applications without disrupting other business, because the work can be done collaboratively and spread over a period of time. The upgrade module in Angular 2 has been designed to make incremental upgrading seamless.

and

When we use UpgradeAdapter, what we're really doing is running both versions of Angular at the same time. All Angular 2 code is running in the Angular 2 framework, and Angular 1 code in the Angular 1 framework. Both of these are the actual, fully featured versions of the frameworks. There is no emulation going on, so we can expect to have all the features and natural behavior of both frameworks.

What happens on top of this is that components and services managed by one framework can interoperate with those from the other framework. This happens in three main areas: Dependency injection, the DOM, and change detection.

That is, the upgrade module does exactly what you want.

Upvotes: 3

Related Questions