(function () { 'use strict'; angular .module('app') .controller('MainController', main); function main($state, $rootScope, accountRepository, stateHandler, authorizeHelper, errorHandler, webApiConstants) { /* jshint validthis:true */ var vm = this; vm.version = webApiConstants.BUILD_VERSION; if ($rootScope.isAuthenticated == true) { window.ROOT = $rootScope; vm.logout = function () { accountRepository.logout([]).then(function (response, status, headers, config) { if (errorHandler.check(response, status, config) == errorHandler.STATUS.SUCCESS) { // Remove all used user variables for the current session. authorizeHelper.clearUserRules(); // Redirect to login page. $state.go('login'); } }); }; } else { // Save the target url into special manager and use it after successful authorization. stateHandler.save(); $state.go('login'); } vm.goto = function(type) { switch (type) { case 'approval-services': $state.go('main.approvalServices'); break; } }; vm.test = function(){ alert(1); }; } // IoC container. main.$inject = [ '$state', "$rootScope", "repository.account", "appUtils.stateHandler", "helpers.authorize", "appUtils.errorHandler", "webApi.constants" ]; })();