gpt4 book ai didi

Angular 2 项目的文件结构

转载 作者:行者123 更新时间:2023-12-02 21:28:43 25 4
gpt4 key购买 nike

假设我的项目中有如下文件结构(取自文档):

-app
--core
--feature1
--feature2
--shared

那么,我应该在哪里放置类似的内容:

- communicates.service (service to manage communicates (.message(), .error())
- communicates.component (component which is responsible for content of communicates on my page)
- authorization.service
- and for example feature1.service (feature2 uses this service)
- feature2.service

我不确定是否应该将其放入核心或共享。

问候

最佳答案

通常应用程序范围的服务应该保存在core模块中。这样您就可以确保它们是单例,并且不会同时运行同一服务的多个实例。

所以

  • 我会将大部分应用范围的服务保留在 core 模块中
  • 共享模块中的所有常见表现组件、指令、管道、模块
  • 其功能模块中的所有部分特定元素(例如服务、组件...)

你应该读一下这里,它解释得很好:

关于Angular 2 项目的文件结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44756158/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com