myapp1.controller('jgCtrl', function($scope,$http) {
$http.get('a.php',{
params:{type: 1,
element: 2},
}).then(function(res){
alert(res.data);
$scope.items=res.data;
},function(){
alert('falut');
});
});
控制器代码如上,如何写php可以使得php能返回一个json表单使得angular接受?
<li ng-repeat="x in items">
<p style="font-size:20px;line-height:40px; ">
{{x.title}}
</p>
html部分如上
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
php把查询数据库的方法封成api就可以了
你要把items return一下。