I am having a little problem using Jade JS that doesn't let me finish my app. I have a Mongo DB with questions, answers, and comments. I want to display comments under each answer, so I use a FOR loop to compare the answer ID with the 'answer_id' of each comment.
So it would be like this:
for answer in answers
br
a #{answer.user}
span #{answer.date.toLocaleDateString()} (#{answer.date.getHours()}:#{answer.date.getMinutes()})
br
pre #{answer.text}
textarea(id='#{answer._id}',class='comm',placeholder='Comment this answer')
span
a.btn(href='javascript:post("#{answer._id}")') Send
br
br
p asdadsdadas
for comment in comments
if comment
if ('#{comment.answer_id}' == '#{answer._id}')
p '#{answer._id}'
p '#{comment.answer_id}'
hr
The problem is that for Jade this is NOT equal, but if I change it to != to check the '#{answer._id}' and '#{comment.answer_id}' it shows me exactly the same... So I don't know what's going on.
Thanks
You should use
- if (comment.answer_id == answer._id)
instead of
if ('#{comment.answer_id}' == '#{answer._id}')