Advertisement
Guest User

Untitled

a guest
Jul 12th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. var scotchApp = angular.module('myApp', ['ngRoute', 'checkuser', 'registerApp']);
  2.  
  3. // configure our routes
  4.  
  5. scotchApp.config(["$routeProvider", function ($routeProvider) {
  6.  
  7. // route for the home page
  8. $routeProvider.when('/home', {
  9. templateUrl: '../pages/home.html',
  10. controller: 'mainController'
  11. })
  12.  
  13. // route for the about page
  14. $routeProvider.when('/login', {
  15. templateUrl: '../pages/login.html',
  16. controller: 'loginController'
  17. })
  18.  
  19. // route for the about page
  20. $routeProvider.when('/register', {
  21. templateUrl: '../pages/register.html',
  22. controller: 'registerController'
  23. })
  24.  
  25.  
  26.  
  27. scotchApp.run(function ($rootScope) {
  28. $rootScope.showScrollAndGo = function (path) {
  29. if (ref.getAuth()) {
  30. // console.log("User " + authData.uid + " is logged in with " + authData.provider);
  31. $rootScope.authExist = true;
  32. } else {
  33. console.log("User is logged out");
  34. $rootScope.authExist = false;
  35. }
  36. };
  37.  
  38. scotchApp.controller('loginController', function ($scope, $location) {
  39. $scope.myFunctionLogin = function (view) {
  40. if ($scope.showScrollAndGo()) {
  41. $location.path('home');
  42. } else {
  43. $location.path(view);
  44. }
  45. }
  46.  
  47. scotchApp.controller('registerController', function ($scope, $location) {
  48. $scope.myFunctionRegister = function (view) {
  49. $location.path(view);
  50. }
  51. });
  52.  
  53. app.controller("registerUserToFirebaseController", ["$scope", "Auth", function ($scope, Auth, $location) {
  54.  
  55. $scope.createUser = function () {
  56. $scope.message = null;
  57. $scope.error = null;
  58.  
  59. Auth.$createUser({
  60. email: $scope.emailreg,
  61. password: $scope.passwordreg
  62. }).then(function (userData) {
  63. console.log('authData.id ' + userData.uid);
  64. ref.child("users").child(userData.uid).set({
  65. email: $scope.emailreg
  66. });
  67. $scope.myFunctionEditProfile('editprofile');
  68. console.log('$location ' + $location);
  69. }).catch(function (error) {
  70. $scope.error = error;
  71. $scope.message = "error: " + error;
  72. console.log('error ' + error);
  73. });
  74. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement