目前我们有使用 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.
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/