0
即时消息试图做的是在URL中使用ArticleID,例如文章/ 55cf3ea22440c5542c9fa333作为过滤相关注释的参数。Mean.js - 使用URL作为Mongoose参数
控制器
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);
}
});
};
评论和文章与帖子末尾的评论在同一页上,就像在Stackoverflow上一样。网址是http://localhost:3000/#!/articles/55cf3ea22440c5542c9fa333
有没有在控制器查询中使用这种简单的方法?
路线
app.route('/articles/:articleId')
.get(articles.read)
.put(users.requiresLogin, articles.hasAuthorization, articles.update)
.delete(users.requiresLogin, articles.hasAuthorization, articles.delete);
我最近的事情是$ stateProvider。这是一回事吗? – user237462
我编辑了我的帖子以回答你 – chalasr
你可以在https://github.com/angular-ui/ui-router/wiki/URL-Routing找到如何使用路由的所有文档。 – chalasr