Prototyping Angular Resources
ngResource is a useful Angular.js module which aids communication with RESTful data sources. ngResource objects can be extended using prototypes just like any other JavaScript object.
Let’s start with a simple resource called persons. Imagine that a person contains only a name and an id. An example record would be
Now, let’s connect to the resource (which is hosted at myfakeurl.com/persons) using ngResource.
We don’t want our people to be rude, so let’s extend our resource to let them introduce themselves to the JavaScript console.
Any people created using the resource will now be able to introduce themselves.