Saturday 15 January 2011

angular resource - AngularJS: Creating multiple factories for every endpoint? -


After some examples, it appears that we can inject a factory in which one ending for the rest of the service The point is as

  services.factory ('cookie', ['$ resource', function ($ resource) {return $ resource ('/ recipes /: id', {id : '@id'});}]);   

It looks great, but I think that other endpoint ie / users /: id, and / group / id: as you can imagine that the various finishing points The number is increasing. / P>

Therefore there is good practice to keep a separate factory for each endpoint, so ..

  services.factory ('recipe', ['$ resource' , ... ......... services.factory ('user', ['$ resource', ............. services.factory ('group', [' $ Resource ', ...............   

Or is there any other recommended way?

I really like it Not a problem, but because of this I forced several factories to deal with various finishing points

Thank you <

This is a priority.

But anything prevents you from strengthening all your resources inside a factory:

   

No comments:

Post a Comment