mirror of
https://github.com/Febbweiss/CloudBudget-AngularJS.git
synced 2026-03-05 06:45:39 +00:00
Feature: add account switch
This commit is contained in:
26
public/js/global.controller.js
Normal file
26
public/js/global.controller.js
Normal file
@@ -0,0 +1,26 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
angular
|
||||
.module('cloudbudget')
|
||||
.controller('GlobalController', GlobalController);
|
||||
|
||||
GlobalController.$inject = ['$scope', '$rootScope', '$location'];
|
||||
|
||||
function GlobalController($scope, $rootScope, $location) {
|
||||
var vm = this;
|
||||
|
||||
vm.change_account = change_account;
|
||||
vm.current_account = undefined;
|
||||
|
||||
$scope.$watch(function() {
|
||||
return $rootScope.current_account;
|
||||
}, function() {
|
||||
vm.current_account = $rootScope.current_account;
|
||||
}, true);
|
||||
|
||||
function change_account() {
|
||||
$location.path('/account/' + vm.current_account);
|
||||
};
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user