在html5mode angularjs注销URL?html5mode、angularjs、URL

2023-09-13 04:52:13 作者:一别两宽

所以现在我已经配置html5mode。

So right now I have configured html5mode.

    $locationProvider.html5Mode(true);
    $locationProvider.hashPrefix('!');

这是我的middelware为前preSS端支持html5mode

This is end of my middelware for express to support html5mode

app.use(function (req, res) {
    if (!req.path.match('/calendar|/user|/create|/profile')) {
        return res.send(404);
    }
    res.render('home/index', {
        currentUser: req.user
    });
});

和我的所有URL在Chrome和Firefox 3.6(我使用测试hashbang后备其中)。工作好

And all my urls are working good in Chrome and Firefox 3.6(which I'm using to test hashbang fallback).

我唯一的问题是与注销路线。我的注销是一个服务器的交互。所以,我这样做。

My only issue is with the logout route. My logout is a server interaction. So I did this.

    $rootScope.logout = function () {
        window.location = '/logout';
    };

和作出了NG-点击此功能,并且工作在Chrome注销。我怎么会去在hashbang后备模式这样做呢?这不是在Firefox 3.6中工作。谢谢!

And made an ng-click to this function and that worked for logging out in Chrome. How would I go about doing this in the hashbang fallback mode? It's not working in Firefox 3.6. Thanks!

推荐答案

目标=_自我添加到像这样的链接:

Add a target="_self" to the link like this:

<a href="/logout" target="_self">Logout</a>

AngularJS忽略与目标属性的链接。这是记录在这里: HTML链接重写(搜索_self)。

AngularJS ignore links with a target attribute. This is documented here: HTML link rewriting (search for _self).