angularjs 与 UEditor开发,添加directive,保证加载顺序正常
'use strict';
angular.module('app.core').directive('ueditor', [function () {
return {
restrict: 'A',
require: 'ngModel',
link: function (scope, element, attrs, ctrl) { var _initContent = '';
var editor;
var editorReady = false; ctrl.$render = function () {
_initContent = ctrl.$isEmpty(ctrl.$viewValue) ? '' : ctrl.$viewValue;
setContent(_initContent);
}; function init() {
editor = new UE.ui.Editor({
initialContent: scope.content,
wordCount: false, // 字数统计
elementPathEnabled: false, // 元素路径
autoFloatEnabled: false, // 工具栏浮动
autoHeightEnabled: false, // 自动长高
toolbars: [
[
'source', 'fontsize', '|',
'blockquote', 'horizontal', '|',
'removeformat', '|',
'bold', 'italic', 'underline', 'forecolor', 'backcolor', '|',
'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify',
'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
'insertorderedlist', 'i
nsertunorderedlist', '|',
'link', 'unlink', '|',
'insertimage', 'music', 'insertvideo', 'template'
]
]
});
editor.render(element[0]);
editor.ready(function () {
editorReady = true;
setContent(_initContent);
editor.addListener('contentChange', function () {
if (!scope.$$phase) {
scope.$apply(function () {
ctrl.$setViewValue(editor.getContent());
});
}
});
});
}
function setContent(content) {
if (editor && editorReady) {
editor.setContent(content);
}
} init();
}
};
}]);
在html代码中引用
<div name="content" ueditor ng-model="content" ng-change="contentChanged()" ng-required="true"></div>
在controller中初始化及赋值
初始化 $scope.content="";
赋值:$scope.content="<b>abcdefg</b>"
angularjs 与 UEditor开发,添加directive,保证加载顺序正常的更多相关文章
- seajs实现JavaScript 的 模块开发及按模块加载
seajs实现了JavaScript 的 模块开发及按模块加载.用来解决繁琐的js命名冲突,文件依赖等问题,其主要目的是令JavaScript开发模块化并可以轻松愉悦进行加载. 官方文档:http:/ ...
- Linux内核启动代码分析二之开发板相关驱动程序加载分析
Linux内核启动代码分析二之开发板相关驱动程序加载分析 1 从linux开始启动的函数start_kernel开始分析,该函数位于linux-2.6.22/init/main.c start_ke ...
- 基于JRebel开发的MybatisPlus热加载插件
前言 前天项目中使用了mybatis-plus,但是搭配Jrebel开发项目时,发现修改mapper的xml,或者mapper方法中的注解,Jrebel并没有能够reload mapper.于是就有了 ...
- iOS开发UI篇—懒加载
iOS开发UI篇—懒加载 1.懒加载基本 懒加载——也称为延迟加载,即在需要的时候才加载(效率低,占用内存小).所谓懒加载,写的是其get方法. 注意:如果是懒加载的话则一定要注意先判断是否已经有了, ...
- Android开发中如何解决加载大图片时内存溢出的问题
Android开发中如何解决加载大图片时内存溢出的问题 在Android开发过程中,我们经常会遇到加载的图片过大导致内存溢出的问题,其实类似这样的问题已经屡见不鲜了,下面将一些好的解决方案分享给 ...
- 【Java Web开发学习】Spring加载外部properties配置文件
[Java Web开发学习]Spring加载外部properties配置文件 转载:https://www.cnblogs.com/yangchongxing/p/9136505.html 1.声明属 ...
- css样式加载顺序及覆盖顺序深入理解
注:内容转载 很多的新手朋友们对css样式加载顺序和覆盖顺序的理解有所偏差,下面用示例为大家详细的介绍下,感兴趣的朋友不要错过 { height: 100%; width: 200; position ...
- PHP 依赖注入,从此不再考虑加载顺序
说这个话题之前先讲一个比较高端的思想--'依赖倒置原则' "依赖倒置是一种软件设计思想,在传统软件中,上层代码依赖于下层代码,当下层代码有所改动时,上层代码也要相应进行改动,因此维护成本较高 ...
- javascript加载顺序
javascript加载顺序 <script type="text/javascript" src="jquery.js"></script& ...
随机推荐
- JavaScript、CSS样式收集
JS集: //给from一个名字然后在JavaScript的地方就可以用form的名字来调用form表单里input元素的value属性可以得到值 var val=form_name.input_na ...
- idea vs
F8对应vs的F10F7对应vs的F11F9对应vs的F5 ctrl+.对应vs的alt+回车 shift+alt+s 查找文本的出现位置就用Ctrl+F/Ctrl+Shift+F在当前窗口或 ...
- 用树莓派开Wifi热点
安装软件 首先设置软件源: vim /etc/apt/sources.list 查看软件源后面的版本,如果是wheezy,需要换成jessie wheezy是基于deb 7的版本 而现在是基于jess ...
- Android:真机调试遇到的问题(You need to use a Theme.AppCompat theme (or descendant) with this activity)
Android:真机调试遇到的问题(You need to use a Theme.AppCompat theme (or descendant) with this activity). 在调试&l ...
- StanFord ML 笔记 第九部分
第九部分: 1.高斯混合模型 2.EM算法的认知 1.高斯混合模型 之前博文已经说明:http://www.cnblogs.com/wjy-lulu/p/7009038.html 2.EM算法的认知 ...
- Java课程作业之动手动脑(二)
纯随机数发生器 编写一个方法,使用以下算法生成指定数目(比如1000个)的随机整数. import java.util.Scanner; public class test { public stat ...
- 框架: require.js
require.js http://www.bootcdn.cn/require.js/ HTML: <div class="container" data-page=&qu ...
- Linux——JDK配置
一.安装jdk-7u21-linux-x64.rpm文件 [root@centos6 local]# rpm –ivh jdk-7u21-linux-x64.rpm 二.防火墙开放8080端口 (在 ...
- http://www.cnblogs.com/hanshuhe/archive/2012/08/30/vss.html
http://www.cnblogs.com/hanshuhe/archive/2012/08/30/vss.html
- 白鹭引擎 - 碰撞检测 ( hitTestPoint )
1, 矩形碰撞检测 class Main extends egret.DisplayObjectContainer { /** * Main 类构造器, 初始化的时候自动执行, ( 子类的构造函数必须 ...