app.controller('HomeController', ['$scope', 'Auth', 'localStorageService', '$location', function ($scope, Auth, localStorageService, $location) { var vm = this; vm.signOut = function () { localStorageService.remove('userAuth'); $location.path('/splash-page'); } function userAuth() { return JSON.parse(localStorageService.get('userAuth')); } $scope.$watch(Auth.isLoggedIn, function (value, oldValue) { if (!value && !oldValue) { $location.path('/splash-page'); } }, true); }]);