Last active
March 27, 2017 16:45
-
-
Save itswadesh/aa56a2e4ab08025cba8634746ae95982 to your computer and use it in GitHub Desktop.
This file contains 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
app.controller('authCtrl', function ($scope, $rootScope, $routeParams, $location, $http, Data) { | |
//initially set those objects to null to avoid undefined error | |
$scope.login = {}; | |
$scope.signup = {}; | |
$scope.doLogin = function (customer) { | |
Data.post('login', { | |
customer: customer | |
}).then(function (results) { | |
Data.toast(results); | |
if (results.status == "success") { | |
$location.path('dashboard'); | |
} | |
}); | |
}; | |
$scope.signup = {email:'',password:'',name:'',phone:'',address:''}; | |
$scope.signUp = function (customer) { | |
Data.post('signUp', { | |
customer: customer | |
}).then(function (results) { | |
Data.toast(results); | |
if (results.status == "success") { | |
$location.path('dashboard'); | |
} | |
}); | |
}; | |
$scope.logout = function () { | |
Data.get('logout').then(function (results) { | |
Data.toast(results); | |
$location.path('login'); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment