javascript - Output returned data from mongo to jade -


i in console.

[ { __v: 0, city: 'on1', address: '111', first: 'user', last: 'one', chart: 'char1', doctor: 'doc1', _id: 5698a803d98f05482ba48a4b }, { __v: 0, city: 'city2', address: 'address2', first: 'first2', last: 'last2', chart: 'char2', doctor: 'doc2', _id: 5698d7c56d090e5c28b88f83 } ] 

and want values in span tag <span> on1 </span> , <span> address </span>. want this.

patient.find({}, function(err, patients){     console.log(patients)     city = patients[0].city     res.render("table.jade", {test : "test", patient : patients}) }) 

jade:

   each val, index in patients         span= val 

also normal me array? thought object

edit: tried , didn't work.

        - (var g = 0; g < patients.length; g++){         //- // - alert("hello")            span= patients["city"]        - } 

the g in for loop represents index of single patient. should use access patient:

for (var g = 0; g < patients.length; g++) {     span= patients[g]['city'] } 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -