Monday, 5 June 2017

Keeping navbar loaded when navigating to new pages

I'm fairly new to web development, so I appreciate any guidance I can get.

I created a web application before with Express and EJS. Whenever I navigated pages on that application, the navbar would stay at the top at all times even though I was rendering a new EJS file every time.

Now I am creating another web application with Express and AngularJS. I want this same effect, but currently whenever I navigate to a new page, the navbar is reloaded every time. I noticed that instead of using the following in my server.js file

res.render('example.ejs');

I am now using

res.sendFile('example.html');

If I'm not mistaken, res.render() is used for templating engines, which allows for navigating without reloading the navbar. res.sendFile() just send the html file as it is to the client. That being said, is there any way to mimic the behavior of having the navbar being loaded at all times with Express and AngularJS without the use of ngRoute? I am aware ngRoute can create a template that only changes a certain part of the view when navigating to other pages, but I am trying to avoid this.

Once again, any help is appreciated! Thank you guys in advance :)



via calviners

No comments:

Post a Comment