Skip to content

Instantly share code, notes, and snippets.

@dsandip
Last active August 25, 2017 13:10
Show Gist options
  • Save dsandip/f99f2b21337506a60f34f693c0c86e65 to your computer and use it in GitHub Desktop.
Save dsandip/f99f2b21337506a60f34f693c0c86e65 to your computer and use it in GitHub Desktop.
sign up and register for ionic medium article
angular.module('starter.controllers')
.controller('RegisterCtrl', function($scope, hasura, $ionicPopup) {
$scope.loginData = {
username: '',
password: '',
repassword: '',
email: ''
};
$scope.doRegister= function() {
if($scope.loginData.password !== $scope.loginData.repassword) {
$ionicPopup.alert({
title: 'Error',
template: 'Passwords do not match'
});
} else {
hasura.setUsername($scope.loginData.username);
hasura.auth.signup($scope.loginData.password, {}, function(){
console.log('signup success');
$ionicPopup.alert({
title: 'Success',
template: 'Register success'
});
$scope.$apply();
}, function(error){
console.log('signup error');
$ionicPopup.alert({
title: 'Error',
template: 'Register failed'
});
});
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment