简体   繁体   English

在 Angular 2+ 项目中使用 AngularJS Material 组件

[英]Use AngularJS Material components in Angular 2+ project

I develop in Angular 2+ for quite a while using Angular Material, but the documentation of AngularJS Material is more complete and wide then the one to Angular 2+, there is a way to use AngularJS Material components in an Angular 2+ project?我使用 Angular Material 在 Angular 2+ 中开发了很长一段时间,但是 AngularJS Material 的文档比 Angular 2+ 的文档更完整和更广泛,有没有办法在 Angular 2+ 项目中使用 AngularJS Material 组件? More specific on Angular 6更具体的 Angular 6

You will have to run both frameworks simultaneously to make it work.您必须同时运行这两个框架才能使其工作。 While that certainly is possible, it usually isn't desired, especially if there isn't a clear separation between where the AngularJS application and the Angular 2+ application ends and begins (for instance as there would be if you're migration an AngularJS application to Angular 4).虽然这当然是可能的,但通常是不希望的,特别是如果 AngularJS 应用程序和 Angular 2+ 应用程序的结束和开始位置之间没有明确的分离(例如,如果您正在迁移一个 AngularJS应用到 Angular 4)。 AngularJS components, spread around an Angular 2+ application doesn't seem like a desirable situation.围绕 Angular 2+ 应用程序传播的 AngularJS 组件似乎不是一种理想的情况。

Here are some additional issues:下面是一些额外的问题:

Component names may clash Routing may interfere with each other Communication between AngularJS components and Angular 2+ components is difficult I have two suggestions.组件名称可能冲突 路由可能相互干扰 AngularJS 组件和 Angular 2+ 组件之间的通信很困难 我有两个建议。

Either do away with the AngularJS dependency and clean up after the former co-worker.要么取消 AngularJS 的依赖,并在前同事之后进行清理。 Or, create thin wrapper components around Angular2 Material components, that has the same name and signature as the AngularJS material components.或者,围绕 Angular2 Material 组件创建薄包装组件,与 AngularJS 材料组件具有相同的名称和签名。 This is only possible if the components work somewhat similarly.这只有在组件的工作方式有些相似时才有可能。 I recommend the first suggestion, since the latter might only be plausible for the most simple components.我推荐第一个建议,因为后者可能只适用于最简单的组件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM