我正在尝试将登录引入用户在应用程序中导航的方式.
如果该页面符合特定要求,我假装将用户重定向到他导航到登录页面之前的页面
防止来自$ stateChangeStart的事件停止状态改变如预期但当我运行$ state.go('into_somewhere')时我进入一个无限循环
我的角度版本是1.3.1,ui-router是最新版本
.factory('RouteHistory', function ($rootScope,$log, $state, Auth, $urlRouter, $timeout) {
// after the user enter a page
var currentState = '';
// when the user is trying to access a page that he has not permissions
// or that requires the user to be logged in
var pendingState = '';
var isMenuTogglerVisible = false;
var skipFromStateVal = true;
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams){
event.preventDefault();
if (toState.name == 'login' && fromState.name != 'login'){
$log.log('Ui-router: changing to …Run Code Online (Sandbox Code Playgroud) 试图base href为angularjs html5网络应用程序设置正确的值在cordova中工作
最初$locationProvider.html5Mode(true)用于 <base href="/">:
在SO和ui-router 常见问题解答中尝试了一些替代方案:
<base href=".">使用html5模式根据这个答案:
Error: Failed to execute 'pushState' on 'History': A history state object with URL 'https://page/' cannot be created in a document with origin https://example.com<base href="./"> 使用html5模式:
Error: 10 $digest() iterations reached. Aborting!消息尝试使用这里提到的frankwallis解决方案,但没有帮助(相同的错误)没有base href用$locationProvider.html5Mode({enabled: true, requireBase: false});
我的app配置定义如下:
myApp.config(['$locationProvider', '$urlRouterProvider', '$stateProvider', …Run Code Online (Sandbox Code Playgroud) html5 angularjs cordova angular-ui-router angular-ui-router-extras