From c264d908fbf259d5163a6995ef41a94050737f5b Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Wed, 17 Jun 2015 20:59:45 +0300 Subject: [PATCH] Added New dataService - to sync mainController data with other scopes --- templates/js/controllers/mainController.js | 9 ++++++--- templates/js/controllers/settingsController.js | 4 +++- templates/views/index.html | 1 + templates/views/settings.html | 2 ++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/templates/js/controllers/mainController.js b/templates/js/controllers/mainController.js index 9b4a18d..08b10d6 100644 --- a/templates/js/controllers/mainController.js +++ b/templates/js/controllers/mainController.js @@ -1,7 +1,7 @@ angular.module('SeHub') - .controller('mainController', ['$scope', '$rootScope', 'apiService', '$cookies', '$cookieStore', '$location', '$window', + .controller('mainController', ['$scope', '$rootScope', 'dataService','apiService', '$cookies', '$cookieStore', '$location', '$window', - function($scope, $rootScope, apiService, $cookies, $cookieStore, $location, $window) { + function($scope, $rootScope, dataService, apiService, $cookies, $cookieStore, $location, $window) { var token = $cookies['com.sehub.www']; @@ -14,6 +14,7 @@ angular.module('SeHub') } $scope.loadingData = false; $scope.user = data; + dataService.initService($scope); //Start Data Sync Service (For User) console.log(data); if ($scope.user.isFirstLogin) { $scope.menuObj = {}; @@ -24,7 +25,9 @@ angular.module('SeHub') $location.path('/home') } - }) + }); + + $scope.menuItems = [{ "title": "Dash Board", diff --git a/templates/js/controllers/settingsController.js b/templates/js/controllers/settingsController.js index 1afbabc..b13edc8 100644 --- a/templates/js/controllers/settingsController.js +++ b/templates/js/controllers/settingsController.js @@ -1,5 +1,6 @@ angular.module('SeHub') - .controller('settingsController', ['$scope', '$rootScope', 'apiService', '$cookies', '$location', function($scope, $rootScope, apiService, $cookies, $location) { + .controller('settingsController', ['$scope', '$rootScope', 'dataService','apiService', '$cookies', '$location', + function($scope, $rootScope, dataService ,apiService, $cookies, $location) { var token = $cookies['com.sehub.www']; @@ -34,6 +35,7 @@ angular.module('SeHub') $scope.profileMode = "Save Profile"; $scope.profileModeIcon = "fa fa-floppy-o"; } else { + dataService.userBrodcast($scope.user); $scope.profileMode = "Edit Profile"; $scope.profileModeIcon = "fa fa-pencil"; } diff --git a/templates/views/index.html b/templates/views/index.html index cd629d1..c683489 100644 --- a/templates/views/index.html +++ b/templates/views/index.html @@ -81,6 +81,7 @@ + diff --git a/templates/views/settings.html b/templates/views/settings.html index 96b3f74..70c88f7 100644 --- a/templates/views/settings.html +++ b/templates/views/settings.html @@ -31,6 +31,8 @@ I Am a: {{(user.isLecturer) ? "Lecturer" : "Student"}} + +