美好的一天; 我正在学习angularjs,我看了春季网站http://spring.io/guides/gs/consuming-rest-angularjs/中的例子。 问题是视图上没有显示但使用firebug,我可以看到数据是从服务器返回的。 这是我的控制器
function AController($scope, $http){
$http.get('http://127.0.0.1:5000/auth/users').
success(function(data){
$scope.user = data;
});
}
和我的观点
<div class="container" ng-controller="AController">
<p>Email is {{user.email}}</p>
<p>password is {{user.password}}</p>
</div>
有人可以告诉我我做错了吗?
哦,这是从服务器返回的数据
[
{
"email": "azy@yahoo.com",
"id": 15,
"isActive": null,
"password": "$6$rounds=93733$jj3PWiZjtc0yC1Ws$bCIpDORaYFUDD.8kRRGpV64rMqFFQgR9ujlQEeTSd4r/To1snucdg.fsy2Ovkz39tRpy18ZWQnN7dKomdapKx."
},
{
"email": "abd@yahoo.com",
"id": 16,
"isActive": null,
"password": "$6$rounds=100762$uSVOZI5oPAtEaDn9$HqqfIYQVw7g2ITH7IzK/SnCXBnKJW9wQTjSiJ16BGogkWFh89iC2/SjEY/OEXNrB/YHGI66R.wjwgg5n.2R5P0"
},
{
"email": "xvc@yahoo.com",
"id": 17,
"isActive": null,
"password": "$6$rounds=94664$A/yXLhEW57Sd3ymD$unFuK75sG6jbvH9b2eQTcnIIjYi16NmSCPSxgPR7noE.JSmZDCtvxctY1s9t69nRj5IZMviPEhopnci9CpBaX/"
}
]
答案 0 :(得分:0)
您返回的数据是数组。所以HTML看起来应该与此类似:
<div class="container" ng-controller="AController">
<div ng-repeat="u in user">
<p>Email is {{ u.email }}</p>
<p>password is {{ u.password }}</p>
</div>
</div>