AngularJS access service from different module

A Module is a collection of configuration and run blocks which get applied to the application during the bootstrap process. Modules can list other modules as their dependencies. Depending on a module implies that required module needs to be loaded before the requiring module is loaded.

var myModule = angular.module('myModule', ['module1','module2']);

When you injected your module, the services got registered during the configuration phase and you could access them, so to make a long story short, it’s the correct behavior and the core fundamentals of dependency injection in Angular.
For example

angular.module('module1').service('appservice', function(appservice) {
   var serviceCall = $http.post('api/getUser()',"Role");
});

So how it can be accessed using angular.module('myModule');

angular.module('myModule').controller('appservice', function(appservice)
{
    var Servicedata= appservice.ServiceCall('role');
}

This how it can be accessed. If anyone has another suggestion please say so.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)