From 73d9a65dab043d2f489727f3a565b12298ed4c68 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Mon, 15 Jun 2015 18:41:44 +0300 Subject: [PATCH] AngularJS: Fixed Scope Issue & more Starting to work on the mailController --- templates/index.html | 10 ++++----- templates/js/app.js | 7 +++--- templates/js/controllers/mainController.js | 15 ++++++++----- templates/views/index.html | 26 +++++++++++++++++++--- 4 files changed, 42 insertions(+), 16 deletions(-) diff --git a/templates/index.html b/templates/index.html index e612d8e..a94ff2e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -32,11 +32,11 @@ - - - - - + + + + + diff --git a/templates/js/app.js b/templates/js/app.js index 46b8d12..9b93421 100644 --- a/templates/js/app.js +++ b/templates/js/app.js @@ -14,8 +14,10 @@ welcome.controller('welcomeController', ['$scope', 'apiService', '$cookies', '$w console.log("Welcome Controller"); var uid = $cookies['com.sehub.www']; - if(uid) + if(uid){ + console.info("Session in Place"); $window.location.href = DEBUG ? 'http://localhost:8080/home' : 'http://se-hub.appspot.com/home'; + } @@ -26,8 +28,7 @@ app.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) { $routeProvider .when('/', { - templateUrl: 'templates/views/home.html', - controller: 'mainController' + templateUrl: 'templates/views/home.html' }) .when('/register', { templateUrl: 'templates/views/register.html', diff --git a/templates/js/controllers/mainController.js b/templates/js/controllers/mainController.js index c27cf90..d05f895 100644 --- a/templates/js/controllers/mainController.js +++ b/templates/js/controllers/mainController.js @@ -1,19 +1,24 @@ angular.module('SeHub') .controller('mainController', ['$scope', '$rootScope', 'apiService', '$cookies', '$location', function ($scope, $rootScope, apiService, $cookies, $location) { - $rootScope.seToken = $cookies['com.sehub.www']; - var token = $rootScope.seToken; + var token = $cookies['com.sehub.www']; + $scope.loadingData = true; + $scope.isInRegisterMode = false; apiService.getUserByToken(token).success(function(data){ - console.log(data); - if(data.message == 'No User Found') + if(data.message == 'No User Found'){ console.error("No User Found!"); + } $scope.user = data; $rootScope.user = data; - if($scope.user.isFirstLogin) + if($scope.user.isFirstLogin){ + $scope.menuObj = {}; + $scope.isInRegisterMode = true; + $scope.loadingData = false; $location.path('/register') + } }) $scope.loadingData = false; diff --git a/templates/views/index.html b/templates/views/index.html index 816e633..fcc374d 100644 --- a/templates/views/index.html +++ b/templates/views/index.html @@ -8,8 +8,8 @@ - - + +