angularjs - secondary level routing in node js changes root directory -
in web project using angular js , node js both @ same time.
for routing url in angular js have used below code
app.config(function($routeprovider,$locationprovider) { $routeprovider .when("/expert/:expertname*", { templateurl : "public/views/individual_expert.html", controller:"usercontroller" }) .otherwise({ redirectto:"/home" }) $locationprovider.html5mode(true); });
in above case url generated follows , page displayed properly.
this same thing executed when refresh page same url browser node js code executed. code snippet below
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'); });
at time errors see on browser follows
1.) css paths changed.
2.) js paths changed.
the thing noticed was changing root directory "expert" , trying search import in directory.
i stuck @ long. thank in advance helping me out.
you can comment if don't question correctly.
in view html page, have /css/style.css
instead of normal css/style.css
Comments
Post a Comment