Pri*_*ala 6 node.js angularjs angular-ui-router mean-stack
在我的web项目中,我同时使用了角度JS和节点JS.
为了在Angular JS中路由我的url,我使用了下面的代码
app.config(function($routeProvider,$locationProvider) {
$routeProvider
.when("/expert/:expertname*", {
templateUrl : "public/views/individual_expert.html",
controller:"usercontroller"
})
.otherwise({
redirectTo:"/home"
})
$locationProvider.html5Mode(true);
});
Run Code Online (Sandbox Code Playgroud)
在上述情况下,生成的URL如下,页面正确显示.
当我使用浏览器中的相同URL刷新我的页面时执行同样的操作我的NODE JS代码被执行.代码片段如下
app.get('/expert/:expertname',function(req,res){
if(req.session.usersession!=null){
if(req.session.usersession.type=="Member")
res.sendfile('index/member_index.html');
else if(req.session.usersession.type=="Expert")
res.sendfile('index/expert_index.html');
else if(req.session.usersession.type =="Admin")
res.sendfile('index/admin_index.html');
else
res.sendfile('index/visitor_index.html');
}
else
res.sendfile('index/visitor_index.html');
});
Run Code Online (Sandbox Code Playgroud)
此时我在浏览器中看到的错误如下
1.)我的所有CSS路径都已更改.
2.)我的所有JS路径都已更改.
我注意到的是它正在用"expert"更改我的根目录并尝试搜索该目录中的所有导入.
我被困在这里很久了.提前谢谢你帮助我.
如果您没有正确回答我的问题,您可以发表评论.
| 归档时间: |
|
| 查看次数: |
47 次 |
| 最近记录: |