I have 2 controllers FirstController, SecondController and a service as follow :
app.factory('Data', function(){
return [];
});
I use the service into both controllers like this :
app.controller("FirstController", function($scope, $http, Data) {
// getting an JSON array using $http.get() and storing it into Data.myArray for example
}
app.controller("SecondController", function($scope, $http, Data) {
// I want to do something like this, to recover the array from the Service
$scope.recoveredArray = Data.myArray;
// then do stuff to the reoveredArray...
}
and finally displaying the recoveredArray from the SecondController to the html view.
Thank you very much in advance.