<分区>
我无法将 $http.get()
中的一个变量的内容传递到此方法之外...它始终是 undefined
。
我用 $rootScope
测试过,但没有用。
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.dataJson = "ERROR";
});
console.log(content);
});