Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/272.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.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 ng repeat中的angularJs响应数组_Javascript_Php_Arrays_Angularjs_Ng Repeat - Fatal编程技术网

Javascript ng repeat中的angularJs响应数组

Javascript ng repeat中的angularJs响应数组,javascript,php,arrays,angularjs,ng-repeat,Javascript,Php,Arrays,Angularjs,Ng Repeat,我有一个API正在响应一个数组。我想用ng repeat列出它 下面是PHPAPI代码 connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT id, First_Name, Last_time,Email,Phone_Number,Location,Phd_Degree,Phd_University,MS_Degree,MS_Uni

我有一个API正在响应一个数组。我想用ng repeat列出它

下面是PHPAPI代码

connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT id, First_Name, Last_time,Email,Phone_Number,Location,Phd_Degree,Phd_University,MS_Degree,MS_University,BS_Degree,BS_University FROM user"; $result = $conn->query($sql); $data=array(); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { $data[]=array( 'id'=>$row['id'], 'First_Name'=>$row['First_Name'], 'Last_time'=>$row['Last_time'], 'Email'=>$row['Email'], 'Phone_Number'=>$row['Phone_Number'], 'Location'=>$row['Location'], 'Phd_Degree'=>$row['Phd_Degree'], 'Phd_University'=>$row['Phd_University'], 'MS_Degree'=>$row['MS_Degree'], 'MS_University'=>$row['MS_University'], 'BS_Degree'=>$row['BS_Degree'], 'BS_University'=>$row['BS_University'] ); //echo "id: " . $row["id"]. " - Name: " . $row["First_Name"]. " " . $row["Last_time"]. "
"; } } else { $data[]=array( 'message'=>'not success', ); } print_r($data); //return $dat=json_encode($data); $conn->close(); ?> 连接(U错误){ die(“连接失败:”.$conn->connect\U错误); } $sql=“从用户处选择id、姓名、最后时间、电子邮件、电话号码、位置、博士学位、博士大学、硕士学位、硕士大学、学士学位、学士学位”; $result=$conn->query($sql); $data=array(); 如果($result->num_rows>0){ //每行的输出数据 而($row=$result->fetch_assoc()){ $data[]=数组( 'id'=>$row['id'], 'First_Name'=>$row['First_Name'], “Last_time”=>$row[“Last_time”], 'Email'=>$row['Email'], “电话号码”=>$row[“电话号码”], 'Location'=>$row['Location'], “博士学位”=>$row[“博士学位”], “博士大学”=>row美元[“博士大学”], 'MS_Degree'=>$row['MS_Degree'], 'MS_University'=>$row['MS_University'], “学士学位”=>$row[“学士学位”], “英国理工大学”=>美元行['英国理工大学'] ); //echo“id:.$row[“id”]。-Name:.$row[“First_Name”]。$row[“Last_time”]。
”; } }否则{ $data[]=数组( '消息'=>'未成功', ); } 打印(数据); //返回$dat=json_encode($data); $conn->close(); ?> 这是我的角度代码

app.controller('listuser', function ($scope,$http,$log) { $scope.data=[]; return $http({ method: 'POST', url: 'apisource.php', }) .then(function (results) { $scope.data=results.data; $log.log($scope.data); }); }); app.controller('listuser',函数($scope,$http,$log){ $scope.data=[]; 返回$http({ 方法:“POST”, url:'apisource.php', }) .然后(函数(结果){ $scope.data=results.data; $log.log($scope.data); }); }); 现在的问题是,当我试图在html上实现它时,它不起作用

下面是html代码

{{x.First_Name}} {{x.名字} 我认为问题出在我的响应中,因为它不是Json格式的,但是当我尝试执行Json_encode()时,在响应中它显示为空白

这是我的控制台中显示的响应

Array ( [0] => Array ( [id] => 1 [First_Name] => Zachary [Last_time] => Chatha [Email] => kouda@gmail.com [Phone_Number] => 7745752121 [Location] => Guden�vej 1, 20 Vanl�se, Denmark, Apt 2 [Phd_Degree] => test [Phd_University] => test [MS_Degree] => Master of Science in Pharmaceutical Sciences (MSPS) [MS_University] => Copenhagen University (Denmark) [BS_Degree] => \nBachelor of Science, Biological Applications and Technologies\n [BS_University] => University of Ioannina (Greece) ) [1] => Array ( [id] => 2 [First_Name] => Gaurav [Last_time] => Kumar [Email] => gtest@gmail.com [Phone_Number] => 7745752121 [Location] => Guden�vej 1, 20 Vanl�se, Denmark, Apt 2 [Phd_Degree] => test [Phd_University] => test [MS_Degree] => Master of Science in Pharmaceutical Sciences (MSPS) [MS_University] => Copenhagen University (Denmark) [BS_Degree] => \nBachelor of Science, Biological Applications and Technologies\n [BS_University] => University of Ioannina (Greece) ) ) 排列 ( [0]=>阵列 ( [id]=>1 [名字]=>Zachary [上次]=>Chatha [电子邮件]=>kouda@gmail.com [电话号码]=>7745752121 [位置]=>古登�vej 1,20 Vanl�东南,丹麦,Apt 2 [博士学位]=>测试 [Phd_University]=>测试 [硕士学位]=>药学科学理学硕士(MSPS) [MS_University]=>哥本哈根大学(丹麦) [学士学位]=>\n科学、生物应用和技术学院\n 艾奥尼纳大学(希腊) ) [1] =>阵列 ( [id]=>2 [名字]=>Gaurav [上次]=>Kumar [电子邮件]=>gtest@gmail.com [电话号码]=>7745752121 [位置]=>古登�vej 1,20 Vanl�东南,丹麦,Apt 2 [博士学位]=>测试 [Phd_University]=>测试 [硕士学位]=>药学科学理学硕士(MSPS) [MS_University]=>哥本哈根大学(丹麦) [学士学位]=>\n科学、生物应用和技术学院\n 艾奥尼纳大学(希腊) ) )
在php中,使用json头打印,而不是返回:

header('Content-Type: application/json');
echo json_encode($data);

x从何而来,是否在ng repeat中?是的,它在ng repeat=“x in data”中,如下图所示。@MaKWhat you get in
results
在angular中,从PHP端发送日期,json编码。逻辑上一定有错误。你在做“回声”吗?PHP文件中一定有错误,请通过更改错误报告(E_ALL)进行检查;据我所知,没有错误,只是没有被json_编码()。是的,我正在使用Echo。@Mahavir