這裏是我的路由配置:角`ui路由器 - 如何解決從狀態空錯誤?
$stateProvider
.state('login', {
url: '/',
templateUrl: function(){
return 'app/login/login.html';
},
controller: 'loginCtrl as ctrl',
data: {
requireLogin: false
}
})
.state('loginSerial', {
url: '/login/createCase?sn=',
templateUrl: function(){
return 'app/login/login.html';
},
controller: 'loginCtrl as ctrl',
data: {
requireLogin: false
}
})
上$stateChangeStart
- 我重定向爲:
if(!$rootScope.isUserLoggedIn && !$rootScope.serialLogin){
console.log('no one is logged in!', toParams.sn);
$state.go('/login/createCase',{sn:toParams.sn});;
event.preventDefault();
return;
}
它工作正常。但我得到以下錯誤:
angular.js:11706 Error: Could not resolve '/login/createCase' from state ''
at Object.transitionTo (angular-ui-router.js:3179)
at Object.go (angular-ui-router.js:3107)
at index.route.js:152
at Scope.$broadcast (angular.js:14889)
at Object.transitionTo (angular-ui-router.js:3272)
at Array.<anonymous> (angular-ui-router.js:2383)
at Object.invoke (angular.js:4219)
at handleIfMatch (angular-ui-router.js:1868)
at angular-ui-router.js:1925
at check (angular-ui-router.js:2041)
如何解決此問題?我的身體出了什麼問題?任何一個幫助我?
是的,現在錯誤消失了。但頁面不顯示,但在我登錄頁面顯示錯誤之前。什麼東西需要進一步微調? – user2024080
@ user2024080在您的url中爲您的狀態'/ login/createCase?sn ='移除'=',這樣它就是'/ login/createCase?sn'。這是基於文檔https://github.com/angular-ui/ui-router/wiki/URL-Routing#query-parameters –