Angular Share Variable betwen $http.get and controller [duplicate]
问题 This question already has answers here : How do I return the response from an asynchronous call? (36 answers) Closed 4 years ago . I can't pass the content of one variable inside $http.get() to outside of this method... it's always undefined . I tested with $rootScope , but it didn't work. controller('myControl', function ($scope, $http) { var content; $http.get('../Json/data.json').success(function (data, content) { content = data; }).error(function (data, status, headers, config) { $scope