Skip to content

Instantly share code, notes, and snippets.

@sivaprasadreddy
Created September 5, 2014 12:11
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 sivaprasadreddy/522fb12b3e4b22c1d0ca to your computer and use it in GitHub Desktop.
Save sivaprasadreddy/522fb12b3e4b22c1d0ca to your computer and use it in GitHub Desktop.
provider-service.js
angular.module('myApp')
.provider('UserService', function() {
return {
this.$get = function($http) {
var service = this;
this.user = {};
this.login = function(email, pwd) {
$http.get('/auth',{ username: email, password: pwd}).success(function(data){
service.user = data;
});
};
this.register = function(newuser) {
return $http.post('/users', newuser);
};
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment