Open ghost opened 9 years ago
I've been using the following, @giannico:
angular.module( "app" )
.factory( "users", userFactory );
.factory( "userPosts", userPostsFactory );
function userFactory ( Restangular ) {
return Restangular.service( "users" );
}
function userPostsFactory ( Restangular, users ) {
return function ( userId ) {
return Restangular.service( "posts", users.one( userId ) );
};
}
Anyway, a better solution would be awesome.
I've been favoring the .service method for exposing model resources in my application.
In my application code, I want to retrieve comments subresources under a particular article resource. I'm currently building the URL via option 1 below. I tack a "resourceUrl" onto the resource, so as to not carry a bunch of magic strings throughout the application.
Is there any other best practice way to use the URL builder to chain services? It's a minor inconvenience, just wondering if anyone has a different approach.