相关疑难解决方法(0)

$ on('$ stateChangeStart')内的Ui-Router $ state.go正在引发无限循环

我正在尝试将登录引入用户在应用程序中导航的方式.

如果该页面符合特定要求,我假装将用户重定向到他导航到登录页面之前的页面

防止来自$ 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)

angularjs angular-ui-router

17
推荐指数
3
解决办法
2万
查看次数

angularjs cordova base href

试图base href为angularjs html5网络应用程序设置正确的值在cordova中工作

最初$locationProvider.html5Mode(true)用于 <base href="/">:

  • 应用程序在普通浏览器中完美运行
  • cordova为css/js/templates等提供资源错误
    (我相信它在cordova根目录而不是平台根目录中查找资源?)

在SO和ui-router 常见问题解答中尝试了一些替代方案:

<base href=".">使用html5模式根据这个答案:

  • 找不到资产在cordova(没有资源错误)
  • ui-router进入带有无限循环的尾部旋转和以下错误消息
    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模式:

  • 在cordova找到的资产(没有资源错误)
  • 给我一个可怕的Error: 10 $digest() iterations reached. Aborting!消息尝试使用这里提到的frankwallis解决方案,但没有帮助(相同的错误)

没有base href$locationProvider.html5Mode({enabled: true, requireBase: false});

  • 在cordova找到的资产(没有资源错误)
  • 页面开始加载自己?...在某些州有两次角度引导?

我的app配置定义如下:

myApp.config(['$locationProvider', '$urlRouterProvider', '$stateProvider', …
Run Code Online (Sandbox Code Playgroud)

html5 angularjs cordova angular-ui-router angular-ui-router-extras

8
推荐指数
1
解决办法
2886
查看次数