<div class="col-md-6 text-center">
<div class="text-center form">
<form action="/submitComment" method="post">
Username:<br>
<input type="text" ng-model="username" name="username"><br>
Title:<br>
<input type="text" ng-model="title" name="title"><br>
Body:<br>
<textarea ng-model="body" name="body" cols="40" rows="5" ... ></textarea><br>
<input type="submit" value="Submit">
</form>
</div>
<div class="col-md-6 text-center">
<h3>Username:</h3><br>
{{username}}
<h3>Title:</h3><br>
{{title}}
<h3>Body:</h3><br>
{{body}}
<div class="container">
<div class="col-md-12 text-center margin-top">
<% if (comments) { %>
<h2><%= comments %></h2>
<% } %>
</div>
I'm learning node.js and I'm trying to put this partial(file.html) inside an ejs file. The ng-model part works(first and second block). The third block however doesnt work and prints exactly:
<% if (comments) { %>
<h2><%= comments %></h2>
<% } %>
This is how I'm passing the comments array:
app.get( '/comment' , function(req, res){
myCommentModel.find(function(err, users){
if(err)
throw err;
var tmp = []
for(var i = 0; i < users.length; i++)
tmp.push(users[i].username);
res.render('index', { 'comments' : tmp });
});
});
Appreciate the help..
Aucun commentaire:
Enregistrer un commentaire