Added New dataService - to sync mainController data with other scopes

This commit is contained in:
Sagi Dayan 2015-06-17 20:59:45 +03:00
parent 3465ff3465
commit c264d908fb
4 changed files with 12 additions and 4 deletions

View file

@ -1,7 +1,7 @@
angular.module('SeHub') 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']; var token = $cookies['com.sehub.www'];
@ -14,6 +14,7 @@ angular.module('SeHub')
} }
$scope.loadingData = false; $scope.loadingData = false;
$scope.user = data; $scope.user = data;
dataService.initService($scope); //Start Data Sync Service (For User)
console.log(data); console.log(data);
if ($scope.user.isFirstLogin) { if ($scope.user.isFirstLogin) {
$scope.menuObj = {}; $scope.menuObj = {};
@ -24,7 +25,9 @@ angular.module('SeHub')
$location.path('/home') $location.path('/home')
} }
}) });
$scope.menuItems = [{ $scope.menuItems = [{
"title": "Dash Board", "title": "Dash Board",

View file

@ -1,5 +1,6 @@
angular.module('SeHub') 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']; var token = $cookies['com.sehub.www'];
@ -34,6 +35,7 @@ angular.module('SeHub')
$scope.profileMode = "Save Profile"; $scope.profileMode = "Save Profile";
$scope.profileModeIcon = "fa fa-floppy-o"; $scope.profileModeIcon = "fa fa-floppy-o";
} else { } else {
dataService.userBrodcast($scope.user);
$scope.profileMode = "Edit Profile"; $scope.profileMode = "Edit Profile";
$scope.profileModeIcon = "fa fa-pencil"; $scope.profileModeIcon = "fa fa-pencil";
} }

View file

@ -81,6 +81,7 @@
<!-- Services --> <!-- Services -->
<script src="templates/js/services/apiService.js"></script> <script src="templates/js/services/apiService.js"></script>
<script src="templates/js/services/dataService.js"></script>
<!-- Controllers --> <!-- Controllers -->
<script src="templates/js/controllers/mainController.js"></script> <script src="templates/js/controllers/mainController.js"></script>

View file

@ -31,6 +31,8 @@
I Am a: {{(user.isLecturer) ? "Lecturer" : "Student"}} I Am a: {{(user.isLecturer) ? "Lecturer" : "Student"}}
</div> </div>
</div> </div>
<!-- Starting Edit Mode Div -->
<div layout="column" ng-if="isEditMode"> <div layout="column" ng-if="isEditMode">
<div> <div>
<md-input-container> <md-input-container>