Ueditor是一个强大的富文本编辑器,angular2是一个什么东西就不用多说了吧,但在angular2中又该如何使用它呢?
先前有看过很多的文档,都没有详细的介绍过,既然是美女怎么会没有人看呢?
开始!
1.首先你先要安装依赖包:
npm install ng2-ueditor --save
2.在module中导入Ng2UeditorModule

3.在模板页面使用:
<ng2-ueditor [(ngModel)]="content" [setting]="setting"></ng2-ueditor>
4.在component中也要导入一下

但是这样就OK了吗?
有没有注意到步骤3的那个setting呢?
话不多说,直接上图:

这里有官方的setting配置项:配置项
在ng2-ueditor标签上有一些事件(events),以及方法(methods)

但不要以为这就可以了,还没完呢,最容易忽略的一点:
要在入口的index.html中引入UEditor的JavaScript文件:
<script type="text/javascript" src="assets/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="assets/ueditor/ueditor.all.js"></script>
OK,打完收工!
网友评论