Advertisement
Guest User

Untitled

a guest
May 25th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. //Create a controller to deal with the register form
  2. userModule.controller('RegisterController', ['$http', function($http) {
  3.  
  4. //data will hold all input we need
  5. this.data = {};
  6.  
  7. //Here you connect to the databse and add the new user
  8. this.register = function (mainCtrl, userCtrl) {
  9.  
  10. //TODO: do db magic here
  11. var loggedInUser =
  12. {
  13. name: this.data.name,
  14. email: this.data.email,
  15. password: this.data.password
  16. };
  17. var jsonString = JSON.stringify(loggedInUser);
  18. $http.post("url", loggedInUser).success(function() {
  19.  
  20. console.log("Success");
  21. }).error(function(){
  22. console.log("Failed");
  23.  
  24. });
  25.  
  26. userCtrl.loginUser(loggedInUser); //log the user in
  27. mainCtrl.setLastPageActive(); //Go back to last page
  28. this.data = {}; //Clear the input boxes
  29. }
  30. }]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement