Usage of shared services in angularjs application containing mini SPA’s


GitHub Repository:  GitHub Link

For complete understanding, I have drawn a basic sequence diagram for flow:

Angular: Module Service (onboardingapp.candidate.controller.js)
  // Invoke your service layer for this module​ and will contain .success and .error content of each request
Angular: Module Service (
    // This will serve as abstraction layer for underlying implemntation, Just pass URL, Request Type, Parameter Object
    // FYI -> Its time to get our hand dirty on actual http request, so introduce new Get method in WebAPI home controller

Angular: Global Service (appModule.JS)

     // This will contain shared/global service which will be consumed by all modules for executing CRUD operation,
    // Request Type, URL, Parameter Object will be passed to this shared service, so it will make code more maintainable
    // readable and scalable​. If we dont go through this method then we have to use $http.get() or $ method
    // every where in services files of each module, content negotiation issues can be simply handled over here,
    // If you want to append anything with each URL like ‘Http:\\Jobcorp\’ then instead of copy it on every service file
    // just hard-code this thing in this file and append URL from their respective services.
    // We don’t need to mention protocol and host-name now in every URL request.

For further clarification I have mentioned case of second module, how its controller and service will utilize this global service file.

sequence diagram


One thought on “Usage of shared services in angularjs application containing mini SPA’s

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s