繁体   English   中英

在向angular.js加载状态之前先去特定的控制器

[英]go to a specific controller before loading a state in angular.js

加载网站后,我想重定向到特定状态。 我用下面的代码来做。

angularRoutingApp.run(function ($rootScope, $state, $location, $transitions) {
    $transitions.onStart({}, trans = > {
        $state.go('menuNeurolengua', trans.targetState())
    });
}

但是我抛出了这个问题:

在此处输入图片说明

我该如何解决?

由于您唯一的问题是确定是否刷新了用户刷新的页面或页面,因此您可以执行以下操作(确保注入$ window):

if ($window.performance.navigation.type == 1) {
    console.info( "This page is reloaded" );
} else {
    console.info( "This page is not reloaded");
}

该答案的更多解释: 检查页面是否在Javascript中重新加载或刷新

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM