Last active
September 11, 2016 22:01
-
-
Save oscarr-reyes/d59a64c6c623b1486e68548df62c3132 to your computer and use it in GitHub Desktop.
ngRestful usage example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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