您好我想将来自symfony Back-end的数据绑定为json响应,如下所示。
控制器
app.controller('DashboardCtrl',function($scope,$state,DashBoardServices) {
$scope.allChilds = [];
$scope.getAllChildDetails = function($http) {
DashBoardServices.getAllChild("57cd019afbe0855c0e8b4568")
.then(function (response) {
$scope.allChilds = response.data;
//grant access to the app
if(response.data.MessageId == 1) {
$state.go("child");//want to list all child data in this template
}else{
$state.go("dash");
}
});
}
});
服务
app.factory('DashBoardServices', function($http) {
return {
getAllChild: function (parentId) {
return $http.post('http://127.1.1.0:8080/EduboldPortalApp/eduboldportal/web/app_dev.php/api/all/child', {
parentId: parentId
});
}
});
Json回复
{
"MessageId": 1,
"data": [{
"parentId": "57cd019afbe0855c0e8b4568",
"id": {
"$id": "57ccffd2fbe085880c8b4567"
},
"firstName": "PRATHAMVEER",
"middleName": "SINGH",
"lastName": "CHAHAL"
}, {
"parentId": "57cd019afbe0855c0e8b4568",
"id": {
"$id": "57cd019afbe0855c0e8b4567"
},
"firstName": "GUNSHEEN",
"middleName": "KAUR",
"lastName": "CHAHAL"
}]
}
我有一个名为: allChild.html 的模板,我想列出所有孩子,如下所示:
<ion-content>
<div class="list">
<a ng-repeat="chd in allChilds" class="item item-thumbnail-left">
{{chd.firstName}}
</a>
</ion-content>
但是它没有渲染数据,请帮助我刚开始使用Ionic ..
提前致谢