Skip to content

Instantly share code, notes, and snippets.

@bchhun
Created August 8, 2012 21:00
Show Gist options
  • Save bchhun/3298748 to your computer and use it in GitHub Desktop.
Save bchhun/3298748 to your computer and use it in GitHub Desktop.
AngularJS Resource example
// La couche qui communique avec les URLs REST
angular.module(
'taResource', ['ngResource']
).factory(
'tonDataAccess', function ($resource) {
var url = "/ton/url";
return $resource(
url, {}, { update: { method: 'PUT'} }
);
}
);
angular.module(
'tonApp', ["taResource"]
);
function tonController($scope, taResource) {
var params = {};
taResource.save(params, function(data){ /* ton callback*/ });
taResource.query({id:2});
taResource.update(params);
taResource.delete(params);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment