Tl;dr: 看来是core.module
风格不再是官方的一部分角度风格指南 https://angular.io/guide/styleguide,但它一定是最近才被删除的。导入单例服务的新最佳实践是什么?为什么删除了该样式?
我刚刚读过this https://robferguson.org/blog/2018/11/05/getting-started-with-angular-material/Angular Material 入门指南,它指出
Then (as per the Angular Style Guide) I created a Core module
我检查了时尚指南 https://angular.io/guide/styleguide,但似乎找不到此处引用的指南。在我的搜索过程中,我偶然发现了以下来源:
一篇博文 https://medium.com/@benmohamehdi/angular-best-practices-coremodule-vs-sharedmodule-25f6721aa2ef from Nov. '18解释 core.module 和 shared.module 之间的区别。
这个问题 https://stackoverflow.com/questions/42695931/angular2-coremodule-vs-sharedmodule from Oct. '17对 core.module 有非常详细的解释。
这个问题 https://stackoverflow.com/questions/51477221/angular-6-coremodule-and-sharedmodule from Jul. '18,这没有引起注意。
最后一个问题是指core.module
样式与此链接:
https://angular.io/guide/styleguide#core-feature-module
看来#core-feature-module
锚点已被删除,不再是官方 Angular 风格指南的一部分。只有共享功能模块指南 https://angular.io/guide/styleguide#shared-feature-module遗迹。
为什么是core.module
指南被删除?导入服务等单例的新最佳实践是什么?
嗯,简单说一下从来没有被要求过 https://angular.io/guide/upgrade#say-goodbye-to-angularjs:
您还可以完全删除以下文件。它们是 AngularJS 模块配置文件,在 Angular 中不需要:
- 应用程序/app.module.ajs.ts
- 应用程序/应用程序.config.ts
-
应用程序/核心/core.module.ts
- 应用程序/核心/电话/phone.module.ts
- 应用程序/电话详细信息/电话详细信息.module.ts
- 应用程序/电话列表/电话列表.module.ts
至于它被删除的原因 https://github.com/angular/angular/issues/29848#issuecomment-483321775:
@jenniferfell @brandonroberts 仅供参考。 @jenniferfell 我们删除了CoreModule
作为推荐的技术,因为现在提供服务的首选方式是使用providedIn
,不过@bisonfoutu 有一个很好的观点。我认为这个问题的焦点可能最适合功能模块或SharedModule
部分,但我很想听听团队和社区的意见。
IMO,如果我们得出我们应该建议这种技术的结论,它会走向何方:https://angular.io/guide/styleguide#shared-feature-module https://angular.io/guide/styleguide#shared-feature-module
感谢您提交此问题,@bisonfoutu!
欢迎提出想法! ✨
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)