在没有升级插件的情况下使用angular 1应用中的angular 2组件 [英] Using angular 2 components in angular 1 app without upgrade plugin

查看:62
本文介绍了在没有升级插件的情况下使用angular 1应用中的angular 2组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我们有一个使用lineman-angular-templat,angular 1.5和ES5开发的旧项目

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

我们需要添加新功能,我想将它们添加为angular 2组件.我们没有时间和金钱来使用Angular 2创建新的应用程序.

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.

goad将使用angular 1和ui-routing导航到新页面,并将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.

是否可以在不使用升级插件和将angular 2组件降级为angular 1指令的情况下做到这一点?

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

是否有可能使角1和角2组件一起运行?

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

我真的想利用角度2变化检测机制等的好处

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

推荐答案

角度文档

成功升级的关键之一是通过在同一应用程序中并排运行两个框架,并将Angular 1组件一个接一个地移植到Angular 2中,来逐步进行升级.这使升级甚至大型和复杂的应用程序成为可能,而不会中断其他业务,因为该工作可以协同完成并分散在一段时间内.Angular 2中的升级模块旨在实现无缝升级.

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.

当我们使用UpgradeAdapter时,我们真正要做的是同时运行两个版本的Angular.所有Angular 2代码都在Angular 2框架中运行,而Angular 1代码则在Angular 1框架中运行.这两个都是框架的实际,功能齐全的版本.没有正在进行的仿真,因此我们可以期望拥有两个框架的所有功能和自然行为.

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.

最重要的是,由一个框架管理的组件和服务可以与来自另一个框架的组件和服务进行互操作.这主要发生在三个方面:依赖注入,DOM和更改检测.

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.

这篇关于在没有升级插件的情况下使用angular 1应用中的angular 2组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆