Skip to content

Instantly share code, notes, and snippets.

@andyczerwonka
Last active August 29, 2015 14:15
Show Gist options
  • Save andyczerwonka/4761d372eaece5bef0a7 to your computer and use it in GitHub Desktop.
Save andyczerwonka/4761d372eaece5bef0a7 to your computer and use it in GitHub Desktop.
freezeApp.controller('UserController', function UserController($scope, userService) {
$scope.update = function() {
userService.update($scope.user).success(function() {
// it worked!!
});
};
});
freezeApp.service('userService', function userService($http) {
findAll = function() {
return $http.get('/api/users');
};
findById = function(id) {
return $http.get('/api/users/' + id);
};
create = function(user) {
return $http.post('/api/users', user);
};
update = function(user) {
return $http.put('/api/users', user);
};
delete = function(id) {
return $http.delete('/api/users/' + id);
};
});
@andyczerwonka
Copy link
Author

I'm not sure this works, I'm just trying to show an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment