Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Create a controller to deal with the register form
- userModule.controller('RegisterController', ['$http', function($http) {
- //data will hold all input we need
- this.data = {};
- //Here you connect to the databse and add the new user
- this.register = function (mainCtrl, userCtrl) {
- //TODO: do db magic here
- var loggedInUser =
- {
- name: this.data.name,
- email: this.data.email,
- password: this.data.password
- };
- var jsonString = JSON.stringify(loggedInUser);
- $http.post("url", loggedInUser).success(function() {
- console.log("Success");
- }).error(function(){
- console.log("Failed");
- });
- userCtrl.loginUser(loggedInUser); //log the user in
- mainCtrl.setLastPageActive(); //Go back to last page
- this.data = {}; //Clear the input boxes
- }
- }]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement