admin管理员组文章数量:1389772
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!
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!
Share Improve this question asked Aug 20, 2013 at 19:07 Drew HDrew H 4,7399 gold badges59 silver badges92 bronze badges 8-
You may try
$location.url('/logout')
– zs2020 Commented Aug 20, 2013 at 19:26 - That's the first thing I tried. Doesn't work in or out of html5mode – Drew H Commented Aug 20, 2013 at 19:35
-
Well, I think you may detect the browser to see whether it supports the pushState or not. If not then add the
#!
manually. :) – zs2020 Commented Aug 20, 2013 at 20:03 - 1 The logout url is a traditional url that needs to hit the server. In this case this is not working. All the client side routing is working, in html5mode and in older browsers. Thanks – Drew H Commented Aug 20, 2013 at 20:20
- 2 Have you tried linking like so: <a href="/logout" target="_self">Logout</a>? – bibs Commented Aug 21, 2013 at 2:15
1 Answer
Reset to default 11Add a target="_self" to the link like this:
<a href="/logout" target="_self">Logout</a>
AngularJS ignore links with a target attribute. This is documented here: HTML link rewriting (search for _self).
本文标签: javascriptLogout url in html5mode angularjsStack Overflow
版权声明:本文标题:javascript - Logout url in html5mode angularjs? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744585723a2614184.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论