이것은 일반적인 문제입니다. 톤이 있지만 아무 것도 작동하지 않는 것 같습니다. 여기 내가하는 일이있다. 내 상태로 일부 동적 인 애니메이션을 원합니다. 기본적으로 로그인은 멋진 애니메이션을 실행하고 실제 인터페이스로 이동합니다. 지금, 나는이 같은 전망을 중첩 시작 :
$stateProvider
.state('login', {
url: '/login',
title: "Login",
views: {
"master": {
controller: "LoginController",
templateUrl: "/components/login/login.html",
authentication: false
}
}
})
.state("logout", {
url: "/logout",
title: "Logout",
authentication: false
})
.state('foo', {
url: '/',
controller: "HomeController",
views: {
"master": {
templateUrl: '/components/ui-views/masterView.html'
},
"[email protected]": {
templateUrl: '/components/sidebar/_sidebar.html'
},
"[email protected]": {
templateUrl: '/components/header/_header.html'
}
}
})
.state('foo.inventory', {
url: '/inventory',
title: "Inventory",
views: {
"[email protected]": {
controller: "InventoryController",
templateUrl: "/components/inventory/inventory.html"
}
}
});
그래서 로그 아웃 리디렉션해야하지만이 걸리면이 실행되는 동안. 이 로그 아웃 상태에서 전혀 이동하지 않습니다.
function run($http, $rootScope, $cookieStore, $state, $templateCache, $timeout, AuthService, modalService, const) {
var timeout;
FastClick.attach(document.body);
$rootScope.globals = $cookieStore.get('globals') || {};
if ($state.current.name !== 'login' && !$rootScope.globals.guid) {
$state.go('login');
} else if ($state.current.name == 'login' && $rootScope.globals.guid) {
$state.go('foo');
}
$rootScope.$on('$stateChangeStart', function (event, next, current, fromState, fromParams) {
var authorizedRoles = next.level != undefined ? next.level : 1,
needAuth = next.authentication != undefined ? next.authentication : true;
if (needAuth) {
if (!AuthService.isAuthorized(authorizedRoles, true)) {
event.preventDefault();
if (AuthService.isAuthenticated()) {
$rootScope.$broadcast(const.auth.notAuthorized);
$state.go('foo', {});
} else {
$rootScope.$broadcast(const.auth.notAuthenticated);
}
}
}
if (next.name == 'logout') AuthService.logout($rootScope.globals);
});
}
가 왜이 작동하지 않을 : 여기 나는 것을 처리하고있어 어떻게? 이 일이 잘된 것 같습니다. 그러나
$state.go('login')
은 잘못된 값을 반환합니다.
누군가 올바른 방향으로 나를 인도 할 수 있거나 정확하게 무엇이 잘못되었는지 말해주십시오.
그냥 시도하십시오 window.location.hash = "# login"; $ state.go ('login') 대신에. – Asik
URL 끝 부분에 로그인 만 해시하고 필요한 작업을 수행하지 않습니다. –
많은 부품이 누락되었습니다. $ rootScope.globals.guid 또는 ** if ** rootScope. $ on 이전에 호출 된 곳은 어디입니까? ... 가장 좋은 방법은 문제를 재현하기위한 것이거나 모든 것을 공유하는 것입니다. –