控制器代码如下
var myapp1 = angular.module('myApp', []);
myapp1.controller('wyCtrl', ['$scope','$http',function($scope,$http) {
$http({
method:'get',
url:'/php/search.php'
}).then(function(response){
//成功时执行
console.log(response);
$scope.items = response.items;
},function(response){
//失败时执行
console.log(response);
});
}]);
HTML代码如下
-
{{x.title}}
-
{{x.time}}
php代码
'tyz' , 'time' => 'www.baidu.com'],
['title' => 'zyt' , 'time' => 'www.qq.com'],
];
echo json_encode($data,JSON_UNESCAPED_UNICODE);
?>
控制台輸出Cannot read property '1' of null
页面无法显示内容,另外请问如何修改以上代码才能使得前端向php传递参数
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
控制台输出的什么?你查看一下Network看看返回了什么数据,应该是在response.data中。