大AngularJS应用设计 [英] Large AngularJS application design

查看:142
本文介绍了大AngularJS应用设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要建议在设计上有多个复杂的模块的AngularJS应用程序,并基于该模块被认证和放大器加载后用户的作用;授权。有些用户可能会访问一个简单的模块,有些可能有仪表盘,有些可能有机会获得2+模块。

I need advise on designing an AngularJS application with multiple complex modules and based upon the user role the module gets loaded after authentication & authorization. Some users could have access to one simple module and some could have dashboard and some could have access to 2+ modules.

有很多,我们已经确定的指令,可以在不同的模块可以重复使用的。在设计阶段,我们已经确定了应该存在的,我们有一些以下的项目回答了以下的东西,但我们仍然需要从专家的建议是:

There are lot of directives we have identified which can be reused across different modules. During the design phase we have identified the following things that should exist and we have answers for some of the below items, but we still need advice from experts:


  • 一个模块可以有

    • 局部模板

    • 控制器

    • 指令

    • 服务

    的用户界面的样子,在页的顶部用一个下拉导航顶部留下取决于用户的角色的多个链路的固定的菜单栏。当用户点击一个链接,相应的模块应该得到加载页面。必须有一个空的项目,手动自举,并在运行时加载其他模块。

    UI of the application looks like, a fixed menu bar on the top of the page with a drop down navigation on top left with multiple links depending on the user's role. When the user clicks on a link the corresponding module should get loaded in the page. There has to be an empty project which is manually bootstrapped and loads the other modules at run-time.

    我们的做法是有以下文件夹结构:

    Our approach is to have the following folder structure:


    • 应用

      • 资产

        • CSS

        • LIB JS

        • 图片


        • 指令

        • 公用

        • 验证

        • 服务代理持有$资源调用

        • 枚举

        • 常量


        • 实体JSON(例如客户,产品等)


        • 局部模板

        • 指令

        • 服务

        • 控制器

        所以我的问题是:


        • 哪有模块跟其他模块内的服务?

        • 模块应制定并独立运行?

        • 如何模块之间的通信可以通过传输数据来处理?

        • 如何上述所有内容,特别是异常处理,日志记录?整合

        • 开发商应该明白,我们所定义的惯例?

        • 要调用什么方法进行记录,与模块?发送信息

        推荐答案

        好很多的问题是问;他们似乎是在两大类 - 首先是code结构的问题,第二个是关于指标

        Lots of good questions to be asking; they appear to be in two major groups -- the first is a question of code structure and the second is about metrics (logs, etc.).

        如何能模块跟其他模块内的服务?

        How can a service inside a module talk to other module?

        您最好应使用指令为你的模块。这样,您就可以利用通过要求属性链路控制器的能力。 <一href=\"http://blog.projectnibble.org/2014/01/03/angularjs-sharing-state-between-directives-and-their-controllers/\">Here是指令和控制器之间共享数据的页面。

        You should ideally be using directives for your modules. This way you can leverage the ability to link controllers via the require property. Here is a page on sharing data between directives and controllers.

        模块应制定并独立运行?

        Module should be developed and run independently?

        我假设你正在考虑的单元测试。是的,你的模块最好应是为了使测试更加简单紧密范围成为可能。

        I assume you're thinking about unit testing. Yes, your modules should ideally be as tightly-scoped as possible in order to make testing easier.

        如何模块之间的通信可以通过传输数据来处理?

        How the communication between module can be handled with transferring data?

        这是其中服务通常使用。注:服务,工厂和供应商都意味着AngularJS同样的事情,他们只是稍微不同的方式申报。挑选哪一个你最舒服。

        This is where services are typically used. Note: services, factories and providers all mean the same thing in AngularJS, they're just declared in slightly different ways. Pick whichever one you're most comfortable with.

        如何将所有上述内容,特别是异常处理,整合日志记录?

        How to integrate all the above elements , particularly exception handling, logging?

        日志是一个单独的问题。 AngularJS的好处是,你可以很容易扩大框架的现有部分,以您认为合适的添加功能或行为。为此,您可以使用装饰这里是异常记录的一个例子,我认为将涵盖任何用例您可能感兴趣在

        Logging is a separate issue. The beauty of AngularJS is that you can very easily augment existing parts of the framework in order to add functionality or behaviors as you see fit. You do this using decorators. Here is an example of exception logging that I think will cover any use cases you might be interested in

        开发应该明白,我们所定义的约定?

        Developers should understand the convention we have defined?

        这个问题的答案总是一样的:沟通是他们怎么知道。开发人员需要应酬公约,否则你永远不会买进

        The answer to this is always the same: communication is how they know. Developers need to socialize the convention otherwise you'll never get buy-in.

        要调用什么方法记录,模块之间发送的信息?

        What method to call for logging , sending info between module?

        以上回答。

        这篇关于大AngularJS应用设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆