Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .controller('NewUserCtrl', function($scope, $http, $state, $timeout, $ionicPopup, $ionicLoading) {
- var params = {
- email : $scope.email,
- password : $scope.password,
- password2 : $scope.passwordConfirm,
- profile : 2
- }
- function showAlert(message, title) {
- if (navigator.notification) {
- navigator.notification.alert(message, null, title, 'OK');
- } else {
- alert(title ? (title + ": " + message) : message);
- }
- }
- $scope.showPopupemail = function() {
- var alertPopup = $ionicPopup.alert({
- title: 'Error',
- template: 'Verifica los datos'
- });
- }
- $scope.showPopuppass = function() {
- var alertPopup = $ionicPopup.alert({
- title: 'Error',
- template: 'Las contraseñas no coinciden'
- });
- }
- $scope.registrar = function(){
- $http({
- method: 'POST',
- url: 'http://api.espaciosvirtuales.info/public/index.php/create_userCredentials',
- data: params
- }).then(function successCallback(response) {
- // this callback will be called asynchronously
- // when the response is available
- console.log("Éxito");
- console.log(response)
- $ionicLoading.show({
- template: '<ion-spinner></ion-spinner>'
- });
- $timeout(function() {
- $ionicLoading.hide();
- $state.go('home.explore');
- }, 2000);
- }, function errorCallback(response) {
- // called asynchronously if an error occurs
- // or server returns response with an error status.
- console.log("Error");
- console.log(response);
- response.data = Object.values(response.data).toString();
- showAlert(response.data, 'Error de registro');
- });
- }// FIN DE LA FUNCION REGISTRAR
- $scope.validar = function($params){
- if($scope.email == ''){
- $scope.showPopupemail();
- return false;
- }
- else if($scope.password == ''){
- $scope.showPopupemail();
- return false;
- }
- else if($scope.password != $scope.passwordConfirm){
- $scope.showPopuppass();
- return false;
- }
- else{
- return true
- }
- }// FIN DE FUNCION VALIDAR
- $scope.IsItValidated = function($params){
- if($scope.validar($params) == true){
- $scope.registrar($params);
- }else{
- console.log("No")
- }
- }
- console.log(params)
- console.log("1");
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement