我无法获得{{this.username}}
当我这样做时:
{{#each history}}
{{this.username}} <!--THIS WILL NOT SHOW ANYTHING - OBJ in history->
{{this}} <!-- Shows data just fine, but cant get to any values like line above -->
{{/each}}
{{this}} <!-- THIS WILL SHOW ARRAY OF OBJECTS OK
{{history}}单独输出:
{ _id: 59fe71a6167aaa05f4dcf43c,
userid: 'asd',
name: 'asd',
email: 'asd@asd.com',
passwords: 'asd',
product: 'asd',
issues: 'asd',
serial: 'asd',
accessories: 'asdddddddd',
__v: 0 }
{ _id: 59fe8c8c49830e09d82de3f1,
userid: 'asd',
name: 'asd',
email: 'asd@gmagoaimg.com',
passwords: 'sdfgasdg',
product: 'afafafa',
issues: 'fasfasf',
serial: 'asdfa3a3fasfe',
backedup: 'on',
accessories: 'asdfgasdf',
__v: 0 }
{ _id: 59fe8f26703bf10a2a985f10,
userid: 'asd',
name: 'Homer Gomez',
email: 'ajsidfaos@faksdofa.com',
passwords: 'asdfasdf',
product: 'This is the product',
issues: 'This is the prod desc',
serial: 'afjdofajosdf98988',
backedup: 'on',
accessories: 'asdfasdf',
__v: 0 }
等...
现在,我的路线发送数据,
router.get('/service_history', function(req, res) {
//compares req['user'].name with the Job.userid if the same:
req['user'].service_history = []; // clears the user history
Job.find()
.then( function(doc){
//console.log(doc);
doc.forEach(function(job){
//if (err) throw err
if(job.userid == req['user'].name){
console.log(job);
req['user'].service_history.push(job);
}
});
});
res.render('service_history', { history: {data: req['user'].service_history} } );
});
:{{history}} 当我渲染这个把手代码的页面时,我可以在上面的帖子中渲染我粘贴的对象,
{{#each history}}
感谢您的反馈,并再次抱怨新手的需求