向MEAN.JS文章添加评论 [英] Adding comments to MEAN.JS articles
问题描述
我是新来的平台,我正在使用 MEAN.JS ,它设置了我的身份验证,帐户管理和CRUD模块的文章,我如何添加评论这些文章?有一个困难的时间来得到这个。感谢您的帮助
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? Having a tough time to get this. Thanks for the help
推荐答案
为了在MEAN.js文章示例中添加注释,您需要执行以下步骤: / p>
In order to add comments to your MEAN.js Article example you need to do the following steps:
-
在文件
app / models / article.server.model.js
添加:
comment:{
type:String,
default:'',
trim: true
},
在文件 public / modules / articles / views / -article.html
add:
< div class =form-group>
< label class =control-labelfor =comment>注释< / label>
< div class =controls>
< textarea name =commentdata-ng-model =commentid =commentclass =form-controlcols =30rows =10placeholder =Comment> < / textarea的>
< / div>
< / div>
在文件 public / modules / articles / controllers /articles.client.controller.js
将创建
函数调整为:
var article = new Articles({
title:this.title,
content:this.content,
comment:this.comment
});
在文件 public / modules / articles / views / view-article.client.view.html
在关闭部分之前添加
标签:
< p data-ng-bind =article.comment>< / p>
就是这样,现在每个文章都有一个新的字段 comment
。现在你应该做什么,希望这些指令在这里明确表达,这是改变文章编辑的一部分。
This is it, now you have a new field comment
for each article. What you should do now, and I hope it's clear form these instructions here, is alter the editing part of the articles.
希望这有帮助,祝你MEAN.js好运。而且,既然你提到了一个教程,你可以自由地看看本教程系列。
Hope this helps, good luck with MEAN.js. And, since you mentioned a tutorial, you're free to take a look this tutorial series.
这篇关于向MEAN.JS文章添加评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!