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">
<div style="font-size:20px;line-height:40px; ">
{{x.title}}
</div>
html部分如上
php把查询数据库的方法封成api就可以了