What im trying to do is use an ArticleID in the URL i.e article/55cf3ea22440c5542c9fa333 as the parameter to filter related comments.
Controller
exports.list = function (req, res) {
Comment.find(
{articleID: req.params.articleId}
)
.sort('-created')
.populate('user', 'displayName')
.exec(function (err, comments) {
if (err) {
return res.status(400).send({
message: errorHandler.getErrorMessage(err)
});
} else {
res.jsonp(comments);
}
});
};
The comments and Articles are on the same page with the comments at the end of the post like on Stackoverflow. The url is http://localhost:3000/#!/articles/55cf3ea22440c5542c9fa333
is there a simple way of utilising this in the controller query?
Route
app.route('/articles/:articleId')
.get(articles.read)
.put(users.requiresLogin, articles.hasAuthorization, articles.update)
.delete(users.requiresLogin, articles.hasAuthorization, articles.delete);