I currently have a custom function that includes the following code snippet:
1: var object = get_resource($scope, CbgenRestangular, $stateParams.scheme_id);
2: console.log(object)
This function triggers the following code:
get_resource = function ($scope, CbgenRestangular, id){
CbgenRestangular.one('scheme', id).get().then(function(object){
console.log(object)
return object
})
},
My problem arises when the console.log
within the get_resource
function correctly outputs the object, but on line 2 in the main code snippet it shows as undefined
. Why is this happening?
The object should be the same throughout the entire process, so why does it appear as undefined when I try to return it?