Angular 1.5:基于组件的应用程序的推荐结构?

时间:2016-07-13 04:37:12

标签: angularjs

到目前为止,我一直在使用以下结构构建我的应用程序。

/src
    /components
       /shared
          /messagebox
          /alertbox
       /Home
       /About

因此,您可以看到我共享的组件是在其他组件/页面上使用的组件。我有Home的概念,关于哪些也是组件(转换为可查看的页面),因为角度中的所有内容现在应该是一个组件 - 对吗?

有没有人能更好地实现NG 1.5应用程序的结构?

我现在需要创建一些过滤器,据我所知,我不能将它们从组件中挂起,那么放置这种类型文件的基础位置在哪里?

其他想到的事情还包括污染物,服务等

据我所见,目前还没有针对angular docs网站的建议

任何人都有见解?

由于

1 个答案:

答案 0 :(得分:1)

我以前为我的项目所遵循的是:

project
  /www
    /assets
    /components           // directives
      /accordion
        /accordion.html
        /accordion-directive.js
        /accordion-controller.js
        /accordion-controller-test.js
    /core                 // shared services
       /route
         /router-service.js 
    /sections             // pages we build by adding components
       /registration-page
         /registration.html
         /registration-controller.js
         /registration-controller-test.js
    app.js         
    index.html
    index-controller.js
    app-configuration.json // for keeping constants

这可能会对你有所帮助。请检查。