(function () { 'use strict'; (function () { 'use strict'; app.MenuCtrl = MenuCtrl; angular.module('app.controller').controller('MenuCtrl', MenuCtrl); MenuCtrl.$inject = ['$rootScope', '$scope', '$state', 'user', 'cfg']; function MenuCtrl($rootScope, $scope, $state, user, cfg) { cfg.debug && console.log('MenuCtrl'); if (!user.authenticated) { $state.go('login'); return; } var scopeListeners = []; scopeListeners.push($rootScope.$on('user.logout', function () { $state.go('index'); })); $scope.$on('$destroy', function () { angular.forEach(scopeListeners, function (unbindMethod) { unbindMethod(); }); }); if ('menu' === $state.current.name && user.roleId) { $state.go('menu.' + user.roleId + '.ticket'); } } })(); })();