Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 从Laravel获取AngularJs数据_Javascript_Php_Angularjs_Laravel - Fatal编程技术网

Javascript 从Laravel获取AngularJs数据

Javascript 从Laravel获取AngularJs数据,javascript,php,angularjs,laravel,Javascript,Php,Angularjs,Laravel,您好,我使用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: "exam

您好,我使用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模型中显示数据时

ng-model="user.first_name" 
我看不到视图中的数据

何时执行此操作:

ng-model="user"
返回值为[对象]


等待帮助的家伙,我的问题在哪里?

$scope.user
是一个包含JSON数据的数组。所以你不能像
user.first\u name
那样访问
first\u name
。它应该对你有帮助

<span ng-repeat="info in user">{{info.first_name}}</span>
{{info.first{u name}

或者,更理想的情况是,API应该返回单个对象,而不是数组中的对象。