javascript - 在 Angular 1 应用程序中使用 Angular 2 组件,无需升级插件

标签 javascript angularjs angular

目前我们有使用 lineman-angle-templat、Angular 1.5 和 ES5 开发的旧项目

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

目标是使用 Angular 1 和 ui-routing 导航到新页面,并在新页面中插入 Angular 2 组件。

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

是否可以让 Angular 1 和 Augular 2 组件一起运行?

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

最佳答案

Angular 文档 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.

也就是说,升级模块完全符合您的要求。

关于javascript - 在 Angular 1 应用程序中使用 Angular 2 组件,无需升级插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38688124/

相关文章:

Javascript 将包含文件中的数据发布到父级

angular - 如何在 Angular 2 中缓存 View 或维护历史 View 状态

javascript - Chrome 中的 Firebase Cloud Messaging Service Worker 重定向

php - 谷歌钱包 : How to include the order ID in the success_handler?

angularjs - 由于angularjs中的ng-repeat而出错

angularjs - 无法在 asp.net mvc 中显示来自 s3 存储桶的上传图像

angular - 如何在 Ionic 4 的变化中添加选项卡动画?

Angular 2 : Why do I need classes like Hero. ts?

javascript - 我如何绕过同源策略来为 Google AppEngine 站点开发 AJAX 客户端代码?

java - Spring:引用 resources/static 文件夹