Angular 的 UEditor 插件:Angular-UEditor

jopen 9年前

angualr 作为最近前端大热的一款框架,越来越多国人开始使用并且不断有成功的项目。UEditor作为百度前端团队的一款神器,在国内多个项目也在使用。所以小编抽了个时间把angular和UEditor整合起来作为一款angular的插件。

angular-ueditor

angular-ueditor 是一款整合了 angular 和 UEditor 的插件。目的是为了更方便的在angular基础上使用UEditor。

例子

http://zqjimlove.github.io/angular-ueditor/

安装

先引入 UEditor 的 javascript 文件

<script type="text/javascript" src="/ueditor/ueditor.config.js"></script>  <script type="text/javascript" src="/ueditor/ueditor.all.js"></script>

然后下载最新的 angular-ueditor 并且引入文件

<script type="text/javascript" src="angular-ueditor.js"></script>

此时还需要把 angular-ueditor 引入到模块里

angular.module('app',['ng.ueditor'])

用 Bower 安装

使用 Bower 安装时,angular-ueditor 会自动安装并且引入,但ueditor由于没有加入到 Bower 所以需要手动引入。

bower install angular-ueditor --save

使用

基础用法

由于继承了NgModelController,必须绑定 ngModel

<div class="ueditor" ng-model="content"></div>

自定义编辑器

<div class="ueditor" config="config" ng-model="content"></div>  ...  <script>      $scope.config = {          ...      }  </script>

方法

ready(listener)

注册准备事件,当 editor 初始化完成后会执行回调函数。

参数
参数 类型 详细
listener function(editor) Callback called whenever the editor ready.

例子

<div class="ueditor" ready="ready" ng-model="content"></div>  ...  <script type="text/javascript">      $scope.ready = function(editor){          alert(editor.getContent());      }  </script>

项目主页:http://www.open-open.com/lib/view/home/1411391886875