Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var scotchApp = angular.module('myApp', ['ngRoute', 'checkuser', 'registerApp']);
- // configure our routes
- scotchApp.config(["$routeProvider", function ($routeProvider) {
- // route for the home page
- $routeProvider.when('/home', {
- templateUrl: '../pages/home.html',
- controller: 'mainController'
- })
- // route for the about page
- $routeProvider.when('/login', {
- templateUrl: '../pages/login.html',
- controller: 'loginController'
- })
- // route for the about page
- $routeProvider.when('/register', {
- templateUrl: '../pages/register.html',
- controller: 'registerController'
- })
- scotchApp.run(function ($rootScope) {
- $rootScope.showScrollAndGo = function (path) {
- if (ref.getAuth()) {
- // console.log("User " + authData.uid + " is logged in with " + authData.provider);
- $rootScope.authExist = true;
- } else {
- console.log("User is logged out");
- $rootScope.authExist = false;
- }
- };
- scotchApp.controller('loginController', function ($scope, $location) {
- $scope.myFunctionLogin = function (view) {
- if ($scope.showScrollAndGo()) {
- $location.path('home');
- } else {
- $location.path(view);
- }
- }
- scotchApp.controller('registerController', function ($scope, $location) {
- $scope.myFunctionRegister = function (view) {
- $location.path(view);
- }
- });
- app.controller("registerUserToFirebaseController", ["$scope", "Auth", function ($scope, Auth, $location) {
- $scope.createUser = function () {
- $scope.message = null;
- $scope.error = null;
- Auth.$createUser({
- email: $scope.emailreg,
- password: $scope.passwordreg
- }).then(function (userData) {
- console.log('authData.id ' + userData.uid);
- ref.child("users").child(userData.uid).set({
- email: $scope.emailreg
- });
- $scope.myFunctionEditProfile('editprofile');
- console.log('$location ' + $location);
- }).catch(function (error) {
- $scope.error = error;
- $scope.message = "error: " + error;
- console.log('error ' + error);
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement