I'm trying to pass data from a service to a controller in angular js, the code is the following:
.controller('lista',function($scope,cetrams){
$scope.hola="This is it";
var test;
var testfn = function(){
test = 'Lala';
};
cetrams.success(function(data){
testfn();
test = data;
console.log('Inside service: '+test);
});
console.log('Inside controller: '+test);
})
The service is working, as I get the promise and the function for success is executed, but I cannot get the variable outside that function to the controller scope.