-1

given this http request:

    $scope.obj = {}

    $scope.loadTourInfo = function() {
    var httpRequest = $http({
        method: 'GET',
        url: 'https://s3.amazonaws.com/mirror.discoverhawaiitours.com/activity_object_json/11204.json'
      }).success(function(data) {
        $scope.obj = data;
    });
}

how can I pass the returned object (data) outside of my function's scope?

Alex Hill
  • 713
  • 1
  • 5
  • 13
  • 1
    I don't think this is Angular specific, looks like this very common question http://stackoverflow.com/questions/14220321/how-to-return-the-response-from-an-ajax-call – elclanrs Sep 27 '13 at 01:42
  • Isn't `poop = $scope.obj = data;` outside your function scope if `poop` is declared outside the function? – Brian Sep 27 '13 at 01:43
  • What elclanrs said; this has nothing to do with variable hoisting. – bfavaretto Sep 27 '13 at 01:44
  • This answer may help you http://stackoverflow.com/questions/11252780/whats-the-correct-way-to-communicate-between-controllers-in-angularjs – dohaivu Sep 27 '13 at 01:53

1 Answers1

0

This has nothing to do with variable hoisting. $scope is within the success function's scope so what you're doing should work fine.

Chris Montgomery
  • 2,344
  • 2
  • 19
  • 30