Skip to content

Instantly share code, notes, and snippets.

@oscarr-reyes
Last active September 11, 2016 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oscarr-reyes/d59a64c6c623b1486e68548df62c3132 to your computer and use it in GitHub Desktop.
Save oscarr-reyes/d59a64c6c623b1486e68548df62c3132 to your computer and use it in GitHub Desktop.
ngRestful usage example
var app = angular.module("example", ["ngRestful"]);
// Define global domain for resource
app.config(["ngRestful", function($restful){
$restful.setDomain("http://localhost/tree/server");
}]);
app.controller("exampleController", ["$resource", function($resource){
// Domain is already defined, accounts will be appended with the domain url
var resource = new $resource("accounts");
// Fetch can accept optional parameter to where it will perform a request from accounts
resource.fetch()
.then(function(response){
// successful respone
})
.catch(function(err){
// Error on request
});
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment