5

So right now I have configured html5mode.

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

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
    });
});

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';
    };

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!

4

1 回答 1

11

将 target="_self" 添加到链接中,如下所示:

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

AngularJS 忽略带有目标属性的链接。这在此处记录:HTML 链接重写(搜索 _self)。

于 2013-10-08T20:05:27.317 回答