繁体   English   中英

AngularJS刷新页面(F5)取消路由

[英]Angularjs Refresh page (f5) cancel routing

我的网页上有以下路由:

app.config(function($routeProvider)
{
    $routeProvider
        .when("/",
            {
                //
            })
        .when("/DokumentRoute",
            {
                templateUrl : "static/routes/dokument.html",
                controller : "dokumentController"
            })
        .when("/MarkningarRoute",
            {
                templateUrl : "static/routes/markning.html",
                controller: "markningarController"
            })
        .otherwise(
            {
                templateUrl: "static/routes/pageNotFound.html",
                controller : "pageNotFoundController"
            });
});

刷新页面(F5)时,我想取消路由,这意味着我不想在ng-view标签内显示任何内容

<div ng-view id="view"></div>

这就是现在发生的情况:

当我启动网页时,它没有显示路由页面。 我单击“ dokument”,它会路由到ng-view标签中显示的dokument页面。

当我按F5键时,页面会刷新,但仍显示文档路径!

这就是我要的:

我希望清除路由。 我希望该网站在初次进入时看起来像。 (ng-view标签中未显示任何内容)

我怎样才能解决这个问题?

如果有人感兴趣,这就是我解决的方法:

app.run(function ($location, $rootScope) {

    $rootScope.$on('$routeChangeStart', function (event, next, current) {
        if (!current) {
            $location.path('/');
        }
    });
});

暂无
暂无

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

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