您好我使用laravel和angular js
即时通讯从数据库中获取1个用户数据,但我无法在用户个人资料页面中显示我的用户数据
id = $rootScope.user.id
$http.get('api/users/'+id).success(function(data){
$scope.user = data;
})
我可以在chrome开发人员工具中看到类似的数据:
data: [{id: "308", email: example, first_name: "example", last_name: "example", website: null,…}]
status: 1
但是当我想像这样在ng-model中显示数据时
ng-model="user.first_name"
我无法查看数据
什么时候做:
ng-model="user"
返回是[object Object]
等待帮助的人,我的问题在哪里?
$scope.user
是包含JSON数据的数组。因此,您无法first_name
像一样访问user.first_name
。它应该可以帮助您。
<span ng-repeat="info in user">{{info.first_name}}</span>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句