首页 >

Angularjs编写KindEditor,UEidtor,jQuery指令_AngularJS

web前端|js教程Angularjs编写KindEditor,UEidtor,jQuery指令_AngularJS
AngularJS,指令
web前端-js教程
  目前angularJS非常火热,本人也在项目中逐渐使用该技术,在angularJS中,指令可以说是当中非常重要的一部分,这里分享一些自己编写的指令:
公司转让交易网站源码,vscode统计代码行号,ubuntu木马制作,手动起tomcat,高并发用sqlite3,一个定制爬虫多少钱,卡密生成 php,提高原创率seo,在线背单词网站源码,装饰公司网页模板,网站订单系统模板lzw
  注:本人项目中用了oclazyload进行部分JS文件加载
是男人就下一百层android源码,vscode设置断点没效果,ubuntu 截图工具,tomcat 游戏服务器,sqlite 删除行数,青岛网页设计公司排名,上传到服务器空间,jquery 地区三级联动插件,前端mv框架,爬虫该文件,php比较字符串,高效seo费用,springboot各个层,织梦手机网站模板删除不了,js统计网页访问量,友点cms企业模板下载地址,dede 修改后台,js 鼠标滑动页面,asp.net 题库管理系统,网站程序怎么下载lzw
  1、KindEditor
vb web程序源码,vscode界面是什么,ubuntu用户文件,查看tomcat日志log,sqlite3连接命令行,sm爬虫,php pdf 百度云,泸州seo优化费用,网站建设html,ecshop后台管理模板下载lzw
angular.module('AdminApp').directive('uiKindeditor', ['uiLoad', function (uiLoad) {
return {
restrict: 'EA',
require: '?ngModel',
link: function (scope, element, attrs, ctrl) {
uiLoad.load('../Areas/AdminManage/Content/Vendor/jquery/kindeditor/kindeditor-all.js').then(function () {
var _initContent, editor;
var fexUE = {
initEditor: function () {
editor = KindEditor.create(element[0], {
width: '100%',
height: '400px',
resizeType: 1,
uploadJson: '/Upload/Upload_Ajax.ashx',
formatUploadUrl: false,
allowFileManager: true,
afterChange: function () {
ctrl.$setViewValue(this.html());
}
});
},
setContent: function (content) {
if (editor) {
editor.html(content);
}
}
}
if (!ctrl) {
return;
}
_initContent = ctrl.$viewValue;
ctrl.$render = function () {
_initContent = ctrl.$isEmpty(ctrl.$viewValue) ? '' : ctrl.$viewValue;
fexUE.setContent(_initContent);
};
fexUE.initEditor();
});
}
}
}]);

  2、UEditor:

angular.module("AdminApp").directive('uiUeditor', ["uiLoad", "$compile", function (uiLoad, $compile) {
return {
restrict: 'EA',
require: '?ngModel',
link: function (scope, element, attrs, ctrl) {
uiLoad.load(['../Areas/AdminManage/Content/Vendor/jquery/ueditor/ueditor.config.js',
'../Areas/AdminManage/Content/Vendor/jquery/ueditor/ueditor.all.js']).then(function () {
var _self = this,
_initContent,
editor,
editorReady = false
var fexUE = {
initEditor: function () {
var _self = this;
if (typeof UE != 'undefined') {
editor = new UE.ui.Editor({
initialContent: _initContent,
autoHeightEnabled: false,
autoFloatEnabled: false
});
editor.render(element[0]);
editor.ready(function () {
editorReady = true;
_self.setContent(_initContent);
editor.addListener('contentChange', function () {
scope.$apply(function () {
ctrl.$setViewValue(editor.getContent());
});
});
});
}
},
setContent: function (content) {
if (editor && editorReady) {
editor.setContent(content);
}
}
};
if (!ctrl) {
return;
}
_initContent = ctrl.$viewValue;
ctrl.$render = function () {
_initContent = ctrl.$isEmpty(ctrl.$viewValue) ? '' : ctrl.$viewValue;
fexUE.setContent(_initContent);
};
fexUE.initEditor();
});
}
};
}]);

  3、jquery.Datatable:

angular.module('AdminApp').directive('uiDatatable', ['uiLoad', '$compile', function (uiLoad, $compile) {
return function ($scope, $element, attrs) {
$scope.getChooseData = function () {
var listID = "";
var chooseData = $element.find("input[name = IsChoose]:checkbox:checked");
if (chooseData.length > 0) {
for (var i = 0; i < chooseData.length; i++) {
listID += chooseData[i].value + ",";
}
}
return listID.substring(0, listID.length - 1);
}
$scope.refreshTable = function () {
$scope.dataTable.fnClearTable(0); //清空数据
$scope.dataTable.fnDraw(); //重新加载数据
}
uiLoad.load(['../Areas/AdminManage/Content/Vendor/jquery/datatables/jquery.dataTables.min.js',
'../Areas/AdminManage/Content/Vendor/jquery/datatables/dataTables.bootstrap.js',
'../Areas/AdminManage/Content/Vendor/jquery/datatables/dataTables.bootstrap.css']).then(function () {
var options = {};
if ($scope.dtOptions) {
angular.extend(options, $scope.dtOptions);
}
options["processing"] = false;
options["info"] = false;
options["serverSide"] = true;
options["language"] = {
"processing": '正在加载...',
"lengthMenu": "每页显示 _MENU_ 条记录数",
"zeroRecords": '

没有找到相关数据
',
"info": "当前显示第 _PAGE_ 页 共 _PAGES_ 页",
"infoEmpty": "空",
"infoFiltered": "搜索到 _MAX_ 条记录",
"search": "搜索",
"paginate": {
"first": "首页",
"previous": "上一页",
"next": "下一页",
"last": "末页"
}
}
options["fnRowCallback"] = function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
$compile(nRow)($scope);
}
$scope.dataTable = $element.dataTable(options);
});
$element.find("thead th").each(function () {
$(this).on("click", "input:checkbox", function () {
var that = this;
$(this).closest('table').find('tr > td:first-child input:checkbox').each(function () {
this.checked = that.checked;
$(this).closest('tr').toggleClass('selected');
});
});
})
}
}]);

以上3则就是本人编写的AngularJS指令,这里抛砖引玉下,希望对小伙伴们能有所帮助,


Angularjs编写KindEditor,UEidtor,jQuery指令_AngularJS
  • Angularjs添加排序查询功能代码分享
  • Angularjs添加排序查询功能代码分享 | Angularjs添加排序查询功能代码分享 ...

    Angularjs编写KindEditor,UEidtor,jQuery指令_AngularJS
  • 深入解析AngularJS框架中$scope的作用与生命周期_AngularJS
  • 深入解析AngularJS框架中$scope的作用与生命周期_AngularJS | 深入解析AngularJS框架中$scope的作用与生命周期_AngularJS ...

    Angularjs编写KindEditor,UEidtor,jQuery指令_AngularJS
  • AngularJS控制器继承自另一控制器
  • AngularJS控制器继承自另一控制器 | AngularJS控制器继承自另一控制器 ...