在html5mode angularjs注销URL? [英] Logout url in html5mode angularjs?

查看:227
本文介绍了在html5mode angularjs注销URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以现在我已经配置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).

这篇关于在html5mode angularjs注销URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆