How to get value from Jade to Javascript?

I know this looks repetitive, but this is slightly different from another question here.

I am using Node with expressJS routing and passportJS logic and in my login page I have a dropdown to select the value I want to pass to my Angular script.

In my app.js I have:

var languages = [
   {"lang": "English", "code": "en"},
   {"lang": "Chinese", "code": "zh-cn"}
];
app.get('/', detectBrowser, routes.index);
app.get('/login', routes.login(isSameSubnet, languages));

      

index.js:

exports.index = function(req, res){
   res.render('index', { login: 'Some String' });
};

exports.login = function(language) {
   return function(req, res) {
       res.render('login', { lang: language });
   };
};

      

login.jade:

label.control-label Language
select.form-control
    each val, index in lang
       option(value= val.code)= val.lang

      

So how can I take the value of the option tag back into my javascript and pass it to the next stage (AngularJS)?

I know how to get information from export.index on the Angular side, but I don't know how to get the information I want and use it for this index function.

thank

+3


source to share





All Articles