如何同时使用角度1.3.4和角度2 [英] How to use angular 1.3.4 and angular 2 together

查看:99
本文介绍了如何同时使用角度1.3.4和角度2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经有一个基于angular 1.3.4构建的应用程序,我想将其更改为angular 2,但要在模块方面进行修改.

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.

让我说我的页面上有5个模块,我想将一个模块迁移到angular 2,而其他模块应该像以前使用1.3一样工作,所以我可以慢慢地转换,但直到它不停止工作为止.

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.

我同时包含angular 2和angular 1.3.4库,并且说在控制台中未定义angular

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

推荐答案

请阅读此博客: http://angularjs.blogspot.nl/2015/08/angular-1-and-angular-2-coexistence.html

它说明了如何一起运行以及如何最终升级到Angular 2.

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

此链接的重要之处在于:

The important thing of this link is:

要使其正常工作,需要在Angular 1之间进行四件事互操作 和Angular 2:

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

  • 依赖注入
  • 组件嵌套嵌入
  • 更改检测
  • Dependency injection
  • Component nesting Transclusion
  • Change detection

为了使所有这些成为可能,我们正在建立一个图书馆 名为ng-upgrade.您将在您的产品中包括ng-upgrade和Angular 2 现有的Angular 1应用程序,您将可以随意混合和匹配.

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.

因此您需要ng-upgrade.在此处查看有关此信息的更多信息: https://angular.io/docs/ts/latest/guide/upgrade.html

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

这篇关于如何同时使用角度1.3.4和角度2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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