Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am redirecting to next page after login on expressjs after login, I have some partials to be loaded from angularjs routers which is all fine and working. In res.render I have some data set like this.

res.render('employelogin/employlogin', { title: 'Sheet | Employee',userName: req.session.nameName,DateTime:resultDate,timesheet:timeSheet});

On the Angularjs, I have a jade template which loads fine as told, there I am trying to get the DateTime and Timesheet being printed this is the code

****was at #{DateTime} and was #{timesheet}

I am not getting the datetime and timesheet text being printed here.

** The data for the fileds are coming. I have seen it coming on console **

share|improve this question
 
res.render will just send data to the server templating library (like jade, ejs etc.). It won't send data to angular. For that you need to make another get request to express server from angular –  Mukesh Soni Mar 5 at 15:05
 
I think you misunderstood my question, there is already a get request from DB, I see data coming...I just am sending data to a partial template..so I dont think I need to make one more get request... –  Madhu Mar 5 at 15:37
 
You are confusing server side templating and client side templating. You are using angular templating syntax on server side. You have two options - 1. Get data from db, construct the page server side and send it. 2. Get partial from server, get data from server and fit the data to the placeholders (like in your example) –  Mukesh Soni Mar 5 at 15:39
 
Sorry Mukesh!! I guess today everything is going above my head!! I dint understand the point here...get partials from server.. I my partial file it self I have the #{DateTime}. –  Madhu Mar 5 at 15:54
add comment

1 Answer

I have something like this in my jade template (I'm sending an api object and a token)

    script(type="text/javascript").
        var api = !{JSON.stringify(api)} , token= '!{token}';

I declare both as global variables that I re-use in AngularJS. Hope this helps.

share|improve this answer
 
I dint understand your answer...As told above..I am getting data from DB then the partial template is loading..so I see data there in my console but not on the partial page. –  Madhu Mar 5 at 15:38
 
Right, this is just a line of code I'm using in the jade partial to expose the locals. I'm using !{} instead of #{}. This could be an issue with the version of Jade you're using –  NicolasMoise Mar 5 at 15:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.