Javascript
March 12, 2017
Extending ngResource To Access Metadata
AngularJS’s built-in ngResource is
a great tool for natively supporting REST APIs in your Angular application. But
what happens when you need to support something besides a simple call that
retrieves a list of JSON objects? You quickly run into the limits of ngResource.
Here’s a great case where you might need to do something more complex: paging.
Say you want to get a list of objects, and there’s 10,000 or so of them. You
don’t want to send 10,000 objects to your frontend app. You want to send a
portion of them, but you still need to indicate to the app that there are more.
Surprisingly, considering how widespread this pattern is in web development,
there does not seem to be a native way to accomplish this. But you can extend
ngResource. Here’s how I did it.
Read More