Last active
August 25, 2017 13:10
-
-
Save dsandip/f99f2b21337506a60f34f693c0c86e65 to your computer and use it in GitHub Desktop.
sign up and register for ionic medium article
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
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