让我谈谈我的应用程序:我正在尝试使用节点和角度构建网页。on / (root) url im 提供注册和登录表单。我没有在这里使用角度。成功登录后,我在 /home 上加载 angular 脚本和配置文件。这是我的角度配置文件:
window.app.config(['$routeProvider', '$locationProvider',
function($routeProvider,$locationProvider) {
$locationProvider.html5Mode(true);
$locationProvider.hashPrefix('!');
$routeProvider.
when('/profile', {
templateUrl: '/views/account.html',
}).
when('/edit', {
templateUrl: '/views/edit.html',
}).
when('/home', {
templateUrl: 'views/index.html'
}).
when('/signout', {
templateUrl: 'views/signout.html'
//on this view i load a controller which submits a form to /signout
}).
otherwise({
redirectTo: '/home'
});
}
]);
在服务器端路由:
app.get('/',function(){
res.render('index',{
user: req.user? req.user:'guest'
});
});
app.post('/login',function(){
//if success redirect to /home
//if fails redirect to /
});
app.get('/signout',function(){
//signing out the user here...and redirects to /
});
app.get('/home',function(req,res){
res.render('users/home',{
user: req.user? req.user:'guest',
message: req.flash('error')
})
});
app.get('/profile',function(req,res){
res.render('users/home',{
user: req.user? req.user: 'guest',
message: req.flash('error')
})
});
app.get('/edit',function(req,res){
res.render('users/home',{
user: req.user? req.user:'guest',
message: req.flash('error')
})
});
现在这是问题所在。假设我在 /home url 中。如果我单击此链接,此页面包含一个链接登录页面,角度会将我重定向到 /home 而不是 /。我怎样才能消除这个问题?帮助请:(