Advertisement
Guest User

controller.js

a guest
Aug 10th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. angular.module("membership.controllers", [])
  2.  
  3. .controller("UserController", function ($scope, $state, $ionicModal, $ionicModal, $ionicLoading, UserServices) {
  4.     $scope.signIn = function(user) {
  5.         console.log('Sign-In', user);
  6.         $state.go('tab.dash');
  7.       };
  8.  
  9.     $scope.formLoginData = {};
  10.  
  11.     $scope.formRegistrationData = {};
  12.  
  13.     $scope.userData = JSON.parse(window.localStorage.getItem("userData"));
  14.  
  15.     $ionicModal.fromTemplateUrl("templates/modalRegistration.html", {
  16.         scope: $scope
  17.     }).then(function (modal) {
  18.         $scope.modal = modal;
  19.     });
  20.  
  21.     $scope.signInWithEmail = function () {
  22.         $scope.showLoadingBar("Signing In. . .");
  23.         console.log("Username: " + $scope.formLoginData.username);
  24.         console.log("Password: " + $scope.formLoginData.password);
  25.     };
  26.  
  27.     $scope.signInUsingSocmed = function (authMethod) {
  28.         UserServices.signInWithSocmed(authMethod);
  29.     };
  30.  
  31.     $scope.registerUserWithEmail = function () {
  32.         $scope.showLoadingBar("Signing Up. . .");
  33.         console.log("Username: " + $scope.formRegistrationData.username);
  34.         console.log("Password: " + $scope.formRegistrationData.password);
  35.         $scope.modal.hide();
  36.     };
  37.  
  38.     $scope.showLoadingBar = function (message) {
  39.         $ionicLoading.show({
  40.             template: "<ion-spinner icon='spiral'></ion-spinner> <br/>" + message,
  41.             duration: '2000'
  42.         });
  43.     };
  44.  
  45.  
  46.     // Cleanup the modal when we're done with it!
  47.     $scope.$on('$destroy', function() {
  48.         $scope.modal.remove();
  49.         console.log("Modal Destroyed");
  50.     });
  51.     // Execute action on hide modal
  52.     $scope.$on('modal.hidden', function() {
  53.         // Execute action
  54.         console.log("Modal Hidden");
  55.         $scope.formRegistrationData = {};
  56.     });
  57.     // Execute action on remove modal
  58.     $scope.$on('modal.removed', function() {
  59.         // Execute action
  60.         console.log("Modal Removed");
  61.     });
  62. })
  63.  
  64. .controller('DashCtrl', function($scope, FirebaseSocialAuth) {
  65.     $scope.users = JSON.parse(window.localStorage.getItem("userData"));
  66.     $scope.logout = function () {
  67.         FirebaseSocialAuth.$signOut();
  68.     }
  69. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement