Created
August 8, 2012 21:00
-
-
Save bchhun/3298748 to your computer and use it in GitHub Desktop.
AngularJS Resource 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
// 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