-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
I have a factory :
module.factory('siteService', function($q, $log, JsonldRest) {
var api = {};
JsonldRest.setBaseUrl('/api/v1/');
var entitiesHandler = JsonldRest.collection('sites');
api.findAll = function() {
$log.log('siteService.findAll');
return entitiesHandler.getList();
};
return api;
});
While using the findAll function, I get this error :
Error: Response for getList SHOULD be an array and not an object or something else
This is completely normal as the JSON is like :
{
"@context":"/contexts/Site",
"@id":"/sites",
"@type":"hydra:PagedCollection",
"hydra:totalItems":14,
"hydra:itemsPerPage":30,
"hydra:firstPage":"\/sites",
"hydra:lastPage":"\/sites",
"hydra:member":[
{"@id":"/sites/1","@type":"Site","lang":"es"},
{"@id":"/sites/2","@type":"Site","lang":"en"}
]
}
It is clear I need to work with "hydra:member". But I'd really like a simple way to manipulate the list.
@dunglas has a sweet approach to that :
https://github.com/dunglas/DunglasJsonLdApiBundle#angularjs-integration
What I like is that we can manipulate directly the list (this is what is recommended by mgonto in its demo slide), but, in addition to that, we keep the pagination meta data.
I would be great to have this add-on directly into angular-jsonld in idea to have less code to bootstrap (I know, I'm lazy =P)
Metadata
Metadata
Assignees
Labels
No labels