Angularjs 为什么存储在$scope对象(使用$http.get获取)中的JSON数据没有在绑定表达式中打印出来?
我从jsp获得了jason数据,并存储在angularjs中的$scope对象中。当我试图在绑定表达式内部打印时,数据未打印。但是,当我使用console.log(response)时,数据显示在控制台中 下面是我的代码:Angularjs 为什么存储在$scope对象(使用$http.get获取)中的JSON数据没有在绑定表达式中打印出来?,angularjs,json,Angularjs,Json,我从jsp获得了jason数据,并存储在angularjs中的$scope对象中。当我试图在绑定表达式内部打印时,数据未打印。但是,当我使用console.log(response)时,数据显示在控制台中 下面是我的代码: <!DOCTYPE html> <html ng-app="myApp"> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.5/angul
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.5/angular.js"> </script>
<script>
var myApp=angular.module("myApp",[]);
myApp.controller("myController",function($scope,$http){
$http.get('JSON.jsp')
.then(function(response) {
$scope.array=response.data;
console.log(response.data);
});
//This the jason data I've got:[{"NAME":"jo","AGE":20}]
});
</script>
<meta charset="ISO-8859-1">
<title>AngularCheck</title>
</head>
<body ng-controller="myController" >
{{array.NAME}}
{{array.AGE}}
</body>
</html>
var myApp=angular.module(“myApp”,[]);
controller(“myController”,函数($scope,$http){
$http.get('JSON.jsp')
.然后(功能(响应){
$scope.array=response.data;
console.log(response.data);
});
//这是我得到的jason数据:[{“NAME”:“jo”,“AGE”:20}]
});
角度检查
{{array.NAME}
{{array.AGE}
从图像中可以看到一个对象的数组 因此,将其打印为:
{{array[0].NAME}}
{{array[0].AGE}}
从图像中可以看到一个对象的数组 因此,将其打印为:
{{array[0].NAME}}
{{array[0].AGE}}
HTML
{{array | json}}
你看到了什么?我得到了同样的结果@HTML{{array | json}}中的最大变化
你看到了什么?我得到了相同的结果@马克西舒斯汀