I have two controllers, FirstController and SecondController, along with a service defined as follows:
app.factory('Data', function(){
return [];
});
In both controllers, I am utilizing the service in this manner:
app.controller("FirstController", function($scope, $http, Data) {
// Using $http.get() to retrieve a JSON array and storing it in Data.myArray
}
app.controller("SecondController", function($scope, $http, Data) {
// Attempting to access the array stored in the Service
$scope.recoveredArray = Data.myArray;
// Performing operations on the recoveredArray...
}
Finally, displaying the recoveredArray from SecondController in the html view.
Thank you for your help!