restangular
restangular copied to clipboard
Subelements and Restangularizing them with extendedModels
If I have two distinct factories Person and Team.
angular.module('models')
.factory('Person', function(Restangular){
Restangular.extendCollection('people', function(collection){
collection.findSubset(criteria){
};
return collection;
});
return Restangular.all('people');
})
.factory('Team', function(Restangular){
return Restangular.all('teams');
}
Is there a way to utilize one factory in the other?
For example if I use the Team factory and get a list of people for a team I would like the returned people collection to be enriched by the Person factory model and subsequently have the findSubset() method on the collection.
var peopleOnTeamA = Team.getList().one('teamA').getList('people');
//peopleOnTeamA currently is just a normal Restangular object.
//I would like it to have the added knowledge that it is a Person Restangular object nested within Team.
Does this make sense? Is this possible? Any help would be appreciated.