angular-restclient
Angular-restclient is a angular module to help you simplify any REST-based WebApp. It abstracts a RESTful (json) backend and gives you a extra layer. With that it's super easy to do any HTTP requests as GET, POST, PUT, DELETE and so on.
Features
- Configure all endpoints individually
- Models gives you a whole new flexibility
- Mocks let you develop even when the backend is not fully ready yet
- Simple syntax
- Fully promise based architecture
Getting started
Requirements
- angular > 1.2.x
- angular-resource > 1.2.x
Install
You can ether use bower, npm or git-clone to install angular-restclient. We recommend bower.
bower
$ bower install angular-restclient --save
npm
$ npm install angular-restclient --save
HTML
Load angular-resource.js and angular-restclient.js into your HTML page:
Load Module
Make your application module depend on the restclient module:
var app = angular;
Sample Configuration
The configuration is super simple. This is a sample configuration. We define a baseRoute to the backend with two endpoints users and posts.
app;
Model example
Every endpoint must have a model defined. At first this seems like a lot of work but its worth it. This extra layer gives you a lot of flexibility. For example: When you have to manipulate the RESTful data you can do it once in the model and access it throughout your whole application. Here is a example of a user model:
app;
Make a call
Last we make a call to the backend.
Get all users
app;
Get specific user
app;