I have a function calling an angular resource, to retrieve an item. I want the function to return the value received in the response. Anyway,
function getTemplate (templateId) {
var Tx;
Template.getTemplate({id:templateId})
.$promise.then(
//success
function( response ){
Tx = response.response;
console.log (Tx);
},
//error
function( error ){
Tx = false;
}
);
return Tx
}
When calling Template.getTemplate(123);
I receive undefined, but I should get the response or false;