I have this Angular JS Service:
'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 };
}]);
What I would like to return the value of results.data.
I wanted to do something like the trick _this = this;
and I tried to put that code after .then(
with no success.
My goal is to geth the results.data out of that service.
to be called from a controller simply like this: $scope.myResults = loggedService.out;
{out:undefined}
..?