[英]Adding comments to MEAN.JS articles
I am new to MEAN stack, I am using MEAN.JS , which setup my authentication, account management and a CRUD Module for articles, how do i add comments to these articles? 我是MEAN Stack的新手 ,正在使用MEAN.JS ,它为文章设置了身份验证,帐户管理和CRUD模块,如何为这些文章添加评论? Having a tough time to get this.
很难做到这一点。 Thanks for the help
谢谢您的帮助
In order to add comments to your MEAN.js Article example you need to do the following steps: 为了向您的MEAN.js文章示例添加注释,您需要执行以下步骤:
In the file app/models/article.server.model.js
add: 在文件
app/models/article.server.model.js
添加:
comment: { type: String, default: '', trim: true },
In the file public/modules/articles/views/create-article.html
add: 在文件
public/modules/articles/views/create-article.html
添加:
<div class="form-group"> <label class="control-label" for="comment">Comment</label> <div class="controls"> <textarea name="comment" data-ng-model="comment" id="comment" class="form-control" cols="30" rows="10" placeholder="Comment"></textarea> </div> </div>
In the file public/modules/articles/controllers/articles.client.controller.js
adjust the create
function to be: 在文件
public/modules/articles/controllers/articles.client.controller.js
将create
函数调整为:
var article = new Articles({ title: this.title, content: this.content, comment: this.comment });
In the file public/modules/articles/views/view-article.client.view.html
add this just before the closing section
tag: 在文件
public/modules/articles/views/view-article.client.view.html
,在结尾section
标记之前添加此代码:
<p data-ng-bind="article.comment"></p>
This is it, now you have a new field comment
for each article. 就是这样,现在每篇文章都有一个新的字段
comment
。 What you should do now, and I hope it's clear form these instructions here, is alter the editing part of the articles. 您现在应该做的是,我希望这里的这些说明很清楚,可以改变文章的编辑部分。
Hope this helps, good luck with MEAN.js. 希望这对您有所帮助,祝您MEAN.js好运。 And, since you mentioned a tutorial, you're free to take a look this tutorial series .
而且,由于您提到了一个教程,因此您可以随意阅读本教程系列 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.