0

My serverside code in Node.JS (using Express) is as follows

res.render('index', {
    startDateTime: startDateTime,
    endDateTime: endDateTime
});

I'd like to access startDateTime and endDateTime on the clientside using Javascript. I know I can access them using Jade by doing #{startDateTime} . Is there a similar approach for Javascript?

4

1 回答 1

0

If I understood your question right, you're wanting to send those variables to an external .js file. If that's the problem, I've answered it right here, but I'm quoting it here:

[...] Two ways of solving this problem that we use in my company are:

  1. Take advantage of the data attributes of HTML5.
    They're a great way to store some info, and jQuery can even retrieve them in the JS type you need!

  2. Use <input type="hidden" /> fields.

于 2013-07-09T15:37:01.307 回答