Tuesday 23 May 2017

how to use rendered DBdata in Loop on pug-js

temp.pug

    $(document).ready(function(){
        //tesing
        var docs = '#{docs}';
        console.log(docs);  //[object Object],[object Object]
        console.log(docs[0]._id); // undefined
        console.log('#{docs}'); // [object Object],[object Object]
        console.log('#{docs[0]._id}'); // 1
        for(var i =0 ; i< '#{docs.length}' ; i++){
            console.log('#{docs[i]._id}'); // Error : Cannot read property '_id' of undefined

            //never mind this code --> $('##{docs[i]._id}').modal({ blurring: true}).modal('attach events', '.#{docs[i]._id}')
        }            

I have found Docs on MongoDB

in a Word, passing Docs on mongoDB->nodejsServer(expressFrameWork)->temp.pug

and then... see my code please

umm... i have tried output Docs as you see

but javascript can't aware varible i in forLoop, then get error : Cannot read property '_id' of undefined

how to using it?

ps. my english suck. if my question is garbage, i will delete



via santutu

No comments:

Post a Comment