Simple CRUD
Can you please put some simple CRUD example in Plunker?
+1 I understand how it works but not how to setup a simple application with this. Can you give an example with routing / controllers?
There's a simple example here http://plnkr.co/edit/Sh669ScCQRyD513bzsBx
I'm planning on doing a CRUD example (That's only get & nested resources) using apiary.io as soon as I get some time.
I also want to make some HTML page for this but my CSS abilities suck, so that I can make an example in the website and not in plunkr.
Thanks! Why not use Twitter Bootstrap or Zurb Foundation to make a simple but easy to ready documentation guide? You will only need to worry about content and not about styling.
Yeah, I know about Tw Bootstrap but it still requires some design.
I'll try to make it. Meanwhile, check that plunkr and let me know if that works out for you :).
Anyway,
setting up Restangular would look something like: https://github.com/mgonto/restangular#how-to-configure-them
And the code example in the README is real and it works https://github.com/mgonto/restangular#lets-code
In this last one, you can see how the routes should be for this to work.
They should use nested restful resources, similar to what Rails does with resource command in Routes file
Thanks for a great tool. I am trying out restangular with my JAX-RS webservices. My responses from my webservices will have their data in an array named differently depending on the resource called. For example "/rest/countries" - the data is in {response}.countries. For "/rest/sellers" the data is in {response}.sellers.
If I set an interceptor on the app config this is global and does not provide the current resource (although I am not sure I can make a 1:1 connection between resource path and result data - or at least I'd rather not). Is there a way to set an interceptor on the instance injected into the service where restangular is used? I have tried setting it on Restangular and Restagular.all("countries") but both of these do not seem to provide access to the configuration methods such as setResponseInterceptor(). I am calling .getList( ) to get the items.
I guess what I am missing is how can I apply instance specific configurations beyond the global config?
I am using 0.6.5 and also tried 0.6.6
Hey,
You can actually do that with the responseInterceptor, using instances names.
Take a look at https://github.com/mgonto/restangular#responseinterceptor-or-responseextractor-its-an-alias You'll see that the response interceptor receives actually the model name as the third parameter (what).
So you could do something like follows:
RestangularProvider.setResponseExtractor(function(response, operation, what, url) {
var newResponse;
if (operation === "getList") {
// If what is countries, it'd be response.countries
newResponse = response[what];
} else {
newResponse = response;
}
return newResponse;
});
Hope this works out for you!!!
And also please, if you can next time create a separate issue with your questions. Thanks!!!
There's already a work in progress for this CRUD here:
https://github.com/mgonto/angularjs-talk
There you have some get() and getList() for the time being.
Thanks for your effort. We are waiting for it.
Hey guys,
I've implemented the same project as ANgular's javascript project but with Restangular.
I hope this suits you well :)
Check out http://plnkr.co/edit/bs5Qu8D6mYXzJXR74b87?p=preview
Bests, Gonto