Here's a look at the structure of My Factory:
.factory('MyFactory', function(){
return: {
someFunction: functon(firstParam, secondParam, resultObject) {
$http.get(url).success(resultObject);
}
}
})
And this is how my controller is set up:
.controller('MyCtrl', function($scope) {
MyFactory.someFunction(paramOne, paramTwo, function(resultObj) {
$scope.result = resultObj;
console.log($scope.result) //contains the object
});
console.log($scope.result) //currently returns undefined
}):
I want $scope.result
to be accessible throughout the controller and not just within the callback. As it stands, it can only be accessed within the callback function.
I've identified that the issue lies in the variable scope being limited to the callback function, but I'm unsure on how to resolve this effectively.