我正在尝试通过 id 进行迭代和搜索,并通过控制器中的 $resource 从下面显示的类型的 JSON 对象返回与 id 对应的其他值。我不明白在这种情况下我错在哪里?请帮忙!
这是控制器
appSettings.controller('applistController', ['$scope', 'AppListService',
function($scope, AppListService){
// Have to iterate here to search for an id, how?
// The Above app.json file is returned by the ApplistService(not showing the factory here as it works already.)
$scope.allapps = AppListService.listAllApps().get();
// console.log($scope.allapps.data) returns undefined as so does console.log($scope.allapps.length).
// Where am I wrong?
}
]);
JSON 的类型为:
{"data":[
{
"id":"files_trashbin",
"name": "TrashBin",
"licence":"AGPL",
"require":"4.9",
"shipped": "true",
"active":true
},
{
"id":"files_external",
"name": "External Storage",
"licence":"AGPL",
"require":"4.93",
"shipped":"true",
"active":true
}
],
"status":"success"
}