0

I have an index.ejs "template" page, which has some content which I wish to show on all pages which make use of the template (header, side nav, footer). In my main content area within index.ejs, I simply use angular to render my dynamic content for each individual page.

In my config, I then have different states for "home", "posts", "login" urls. The content of those pages is then rendered as the content within my index.ejs template. This is all fine, since those three pages all follow the same template - they all have a header, side nav, footer and then the content.

My question is, how do I now create a separate "create-post" page, which looks similar to the rest of my pages, but it doesn't have the side nav bar, for example? Do I have to create a new view called create-post.ejs? If so, how do I incorporate that with the rest of my app?

You can view my file structure in my github: http://bit.ly/1Zhg5i3

1 Answer 1

0

Create a new template file and add an hyperlink to that file in the html file which rendered on request to /createpost

Sign up to request clarification or add additional context in comments.

5 Comments

How can I make it such that /createpost displays the content of my new template file (createpost.ejs)? I have added a "router.get('/createpost'.....) in my routes/index.js page, but when I navigate to /createpost, it simply redirects to my home page.
The order in which the route request are written matters. For now, add the create post route before the first route i.e route.get('/',.....). Also in route.get(/createpost, ...) render the createpost.html (the one you want to display and createpost.ejs is linked to). Tell me if it works or not.
Router works as a middleware. If you don't understand how middleware works
Thanks, I have made those changes. If I go to mysite.com/createpost, it displays the contents of createpost.ejs. However, angular appends "#" symbols in my url, and I'm finding it difficult to get around this. All my pages that use the main index.ejs template such as mysite.com/#/home and mysite.com/#/posts redirect accordingly, but if I try and do mysite.com/#/createpost, it still tries to apply my main index.ejs template, and it doesn't display the contents of createpost.ejs.
I don't use angular. On googling I found this it might help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.