Large AngularJS application design

前端 未结 3 2046
北荒
北荒 2021-01-29 22:42

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. S

3条回答
  •  心在旅途
    2021-01-29 23:14

    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?

    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?

    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?

    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?

    Answered above.

提交回复
热议问题