angularjs - How to render templates with express? -


my current setup follows: enter image description here

starting server , going localhost takes me home.ejs stated here (in front end routing):

enter image description here

however, when go localhost:3000/posts, posts template infact not being injected index file (where ui-view is). ive been following mean stack guide thinkster, have been making few changes (not using inline templates)

my question is, how setup routing such localhost:3000/posts take me posts page?

you dealing 2 types of routing, client side , server side. client side located in app.config function in angular code. function should calling html files, located in public directory. these files not rendered server side via express , wouldn't not able read ejs format.

typically mean stack applications, render index file when user logs in, , there angular router takes on html files , handle routing there. if don't want angular routing, have set index.js file render pages called res.render('posts')

you can change posts.ejs file html file, , call via angular when user navigates localhost/#/posts (depending on version , configuration of angular).

your express server side routing handle api calls have defined in index.js. in order call apis, make or post requests via angular's $http method, through service or factory.

hope helps, if not, let me know , can elaborate or provide examples.


Comments