I have been able to get this .factory to work by adding a "return" in front of both the Restangular.all statement and the response. My question is why is it needed there? Why can't I just return the response?
app.controller('MainController', ['GetIndexesFromES', '$scope', function(GetIndexesFromES, $scope) {
$scope.indices = GetIndexesFromES.getUniqueIndexIDs();
console.log($scope.indices);
}]);
app.factory('GetIndexesFromES', ['Restangular', function GetIndexesFromES (Restangular) {
var GetIndexesFromES = {};
GetIndexesFromES.getUniqueIndexIDs = function(){
return Restangular.all('_stats/index,store').getList().then(function(response) {
return response
});
}
return GetIndexesFromES;
}]);
The main reason why I'm asking this question is that I want to modify the data (within the .factory) before sending it back to the controller/$scope.
Thank you, Gregg