javascript - property 'length' of undefined Jade - simple loop -


i rendering jade template using query mongodb through node.

express handling using...

app.get('/rendered', function(req, res){     console.log(mongodoc[0].date + " date 0");     console.log(mongodoc[1].date + " date 1");     res.render('renderme', mongodoc); }); 

the mongodb

{         "date" : "1-may-12",         "close" : "58.13" } {         "date" : "1-apr-12",         "close" : "18.13" } 

the jade template (very new this!)

for result in mongodoc      p #{result.date} 

am using jade incorrectly? there tutorials out there?

when pass mongodoc array template, use json.stringify , parse json in template

app.get('/rendered', function(req, res){     console.log(mongodoc[0].date + " date 0");     console.log(mongodoc[1].date + " date 1");     res.render('renderme', {mongodoc: json.stringify(mongodoc)}); }); 

and inside template

var mongodoc= json.parse('!{mongodoc}'); result in mongodoc     p #{result.date} 

edit: try render data in way

each result in mongodoc     p= result.date 

Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -