Here is a snippet of an Angular JS Service that I have:
'use strict';
app.factory('loggedService', ['$http', 'authService', 'customerService', function ($http, authService, customerService) {
var out = [];
if (authService.authentication.isAuth == false) {
$location.path('/login');
out = "effettuare login";
}
else {
customerService.getCustomerAnagrafica().then(
function (results) {
out = results.data;
}, function (error) {
//alert(error.data.message);
});
}
return { out: out };
}]);
I am trying to figure out how to properly return the value of results.data from this service.
I attempted using the _this = this;
trick by placing it after .then(
, but it did not work as expected.
My objective is to retrieve the results.data from this service.
This would allow me to easily call it in a controller like so:
$scope.myResults = loggedService.out;