Angular updating global variable in all controllers

i have a problem with global variables in Angular.js framework, there are controllers handling array of objects in my application. So i need to update this variable in all controllers when i make 'GET' request to the server for a new data.

I tried do it with services, but the array changes only in controller which initiates get request.

How i can do this?

So do you want to know how to share global variables across contollers?

That you can do with the $rootScope:

https://docs.angularjs.org/api/ng/service/$rootScope

So you just work with $rootScope.yourArrayOfObjs = ....

Also have a look at what the different scopes are in ng

https://docs.angularjs.org/guide/scope


UPDATE: You can of course also do this with a service but not if the sole purpose of the service is to provide the global variables. See angular FAQ last question:

https://docs.angularjs.org/misc/faq

This is a common issue, and you need to store your data in (rather than as) an object in your factory, like:

app.factory('Factory', function() {
    var Factory;
    Factory.data = {}
    Factory.data.sharedAccrossControllers = [1,2,3];
    return Factory;
});