加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – 角度 – 结构模块的最佳实践

发布时间:2020-12-17 09:03:08 所属栏目:安全 来源:网络整理
导读:我是新来的,所以请忍受我.我正在阅读另一天的文章/文档,突出显示了在应用程序中构建模块的最佳方法,只能轻松记住它. App.controllersApp.services....angular.module('App',[App.controllers,App.services ...); 这个代码示例很可能是不正确的,但重点是将控
我是新来的,所以请忍受我.我正在阅读另一天的文章/文档,突出显示了在应用程序中构建模块的最佳方法,只能轻松记住它.
App.controllers
App.services
....

angular.module('App',[App.controllers,App.services ...);

这个代码示例很可能是不正确的,但重点是将控制器,服务等组合在一个命名空间中.

有人可以扩大这种做法吗?

企业项目组织

我组织我的角度项目的方式是:

/app
  /img         # application-level images
  /css         # application-level css styles
  /js          # application-level javascripts
  /modules             # application modules
          /gallery               # independent module with its own infrastructure
                 /controllers    # gallery module's controllers
                 /css            # gallery module's css styles
                 /directives     # gallery module's directives
                 /img            # gallery module's images
                 /filters        # gallery module's filters
                 /services       # gallery module's services
                 /views          # gallery module's views (htmls)
                 / ...           # other gallery module component folders
                 galleryMod.js   # the module itself

          /user                  # independent module with its own infrastructure
                 /controllers    # user module's controllers
                 / ...           # other user module component folders
                 userMod.js      # the module itself

          / ...                  # other modules

  / ...                # other application-level folders
  index.html

替代企业项目组织(简化)

/app
  /img         # application-level images
  /css         # application-level css styles
  /js          # application-level javascripts
  /modules             # application modules
          /gallery               # independent module with its own infrastructure
                 /js             # gallery module's javascripts (includes 
                                 # services.js,directives.js,filters.js,...)
                 /css            # gallery module's css styles
                 /img            # gallery module's images
                 /views          # gallery module's views (htmls,"partials")
                 / ...           # other gallery module component folders
                 galleryMod.js   # the module itself

          /user                  # independent module with its own infrastructure
                 /controllers    # user module's controllers
                 / ...           # other user module component folders
                 userMod.js      # the module itself

          / ...                  # other modules

  / ...                # other application-level folders
  index.html

中间项目组织(无模块)

/app
  /img            # application's images
  /css            # application's css styles
  /controllers    # application's controllers
  /directives     # application's directives
  /filters        # application's filters
  /services       # application's services
  /views          # application's views (htmls)
  / ...           # other component folders
  index.html

简单的项目组织(就像种子)

/app
  /img            # application's images
  /css            # application's css styles
  /js             # application's javascripts (includes 
                  # services.js,...)
  /views          # application's views (htmls),e.g. partials
  / ...           # other component folders
  index.html

使用您的项目需要组织的方式,不要选择不必要的项目复杂化的方式.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读