search
HomeWeb Front-endJS TutorialWrite KindEditor, UEidtor, jQuery instructions in Angularjs_AngularJS

At present, angularJS is very popular, and I am gradually using this technology in my projects. In angularJS, instructions can be said to be a very important part. Here are some instructions I have written:

Note: I used oclazyload to load some JS files in my project

1. KindEditor

Copy code The code is as follows:

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:

Copy code The code is as follows:

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                     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": "Currently displaying page _PAGE_ of _PAGES_",
"infoEmpty": "Empty",
"infoFiltered": "_MAX_ records found",
"search": "search",
“paginate”: {
"first": "Home",
"previous": "previous page",
"next": "Next page",
"last": "last page"
                                                                                                       }                  }
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');
                });
            });
         })
}
}]);

The above 3 are the AngularJS instructions written by me. I hope they can be helpful to my friends.

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
泰拉瑞亚怎么用指令获得物品?-泰拉瑞亚怎么收藏物品?泰拉瑞亚怎么用指令获得物品?-泰拉瑞亚怎么收藏物品?Mar 19, 2024 am 08:13 AM

泰拉瑞亚怎么用指令获得物品?一、什么是泰拉瑞亚给予物品指令在泰拉瑞亚游戏中,给予物品指令是一项非常实用的功能。通过这个指令,玩家可以直接获取需要的物品,而不必费力地去打怪或者传送到某个地点。这样可以极大地节省时间,提高游戏的效率,让玩家更专注于探索和建设世界。总的来说,这个功能让游戏体验变得更加流畅和愉快。二、如何使用泰拉瑞亚给予物品指令1.打开游戏并进入游戏界面。2.按下键盘上的“Enter”键,打开聊天窗口。3.在聊天窗口中输入指令的格式:“/give[玩家名称][物品ID][物品数量]”。

VUE3快速入门:使用Vue.js指令实现选项卡切换VUE3快速入门:使用Vue.js指令实现选项卡切换Jun 15, 2023 pm 11:45 PM

本文旨在帮助初学者快速入手Vue.js3,实现简单的选项卡切换效果。Vue.js是一个流行的JavaScript框架,可用于构建可重用的组件、轻松管理应用程序的状态和处理用户界面的交互操作。Vue.js3是该框架的最新版本,相较于之前的版本变动较大,但基本原理并未改变。在本文中,我们将使用Vue.js指令实现选项卡切换效果,目的是让读者熟悉Vue.js的

2022年最新5款的angularjs教程从入门到精通2022年最新5款的angularjs教程从入门到精通Jun 15, 2017 pm 05:50 PM

Javascript 是一个非常有个性的语言. 无论是从代码的组织, 还是代码的编程范式, 还是面向对象理论都独具一格. 而很早就在争论的Javascript 是不是面向对象语言这个问题, 显然已有答案. 但是, 即使 Javascript 叱咤风云二十年, 如果想要看懂 jQuery, Angularjs, 甚至是 React 等流行框架, 观看《黑马云课堂JavaScript 高级框架设计视频教程》就对了。

探索自带MC指令的输入法的无限可能性(打造完美游戏体验的创新工具——自带MC指令输入法)探索自带MC指令的输入法的无限可能性(打造完美游戏体验的创新工具——自带MC指令输入法)May 02, 2024 pm 03:01 PM

移动设备成为人们生活中必不可少的一部分,在现代社会。而游戏也成为人们闲暇时的主要娱乐方式之一。不断有人致力于开发新的工具和技术来优化游戏玩法,为了提高游戏体验。而自带MC指令的输入法就是其中一种引人注目的创新。以及它如何为玩家们带来更好的游戏体验,本文将深入探讨自带MC指令输入法的无限可能性。自带MC指令输入法简介自带MC指令输入法是一种结合了MC指令和智能输入法功能的创新工具。从而实现更多的操作和功能,通过在移动设备上安装该输入法、玩家可以方便地在游戏中使用各种指令。快速输入指令,提高游戏效率

使用PHP和AngularJS搭建一个响应式网站,提供优质的用户体验使用PHP和AngularJS搭建一个响应式网站,提供优质的用户体验Jun 27, 2023 pm 07:37 PM

在如今信息时代,网站已经成为人们获取信息和交流的重要工具。一个响应式的网站能够适应各种设备,为用户提供优质的体验,成为了现代网站开发的热点。本篇文章将介绍如何使用PHP和AngularJS搭建一个响应式网站,从而提供优质的用户体验。PHP介绍PHP是一种开源的服务器端编程语言,非常适用于Web开发。PHP具有很多优点,如易于学习、跨平台、丰富的工具库、开发效

计算机能直接执行的指令包括哪两个部分计算机能直接执行的指令包括哪两个部分Dec 09, 2020 am 09:15 AM

计算机能直接执行的指令包括操作码和操作数两个部分。操作码是指计算机程序中所规定的要执行操作的那一部分指令或字段,其实就是指令序列号,用来告诉CPU需要执行哪一条指令。

使用PHP和AngularJS构建Web应用使用PHP和AngularJS构建Web应用May 27, 2023 pm 08:10 PM

随着互联网的不断发展,Web应用已成为企业信息化建设的重要组成部分,也是现代化工作的必要手段。为了使Web应用能够便于开发、维护和扩展,开发人员需要选择适合自己开发需求的技术框架和编程语言。PHP和AngularJS是两种非常流行的Web开发技术,它们分别是服务器端和客户端的解决方案,通过结合使用可以大大提高Web应用的开发效率和使用体验。PHP的优势PHP

Prompt都不需要了,动动手就能玩多模态对话系统,iChat来啦!Prompt都不需要了,动动手就能玩多模态对话系统,iChat来啦!May 15, 2023 pm 05:55 PM

夕小瑶科技说原创作者|智商掉了一地近日有很多团队基于用户友好的ChatGPT进行再创作,其中不乏有比较亮眼的成果。InternChat工作强调了用户友好性,这是通过超越语言的方式(光标与手势)与聊天机器人交互来进行多模态任务的。InternChat的命名也比较有趣,代表着互动(interaction)、非语言(nonverbal)和聊天机器人(chatbots),可以简称为iChat。与现有依赖纯语言的交互系统不同,iChat通过加入指向指令,显著提高用户与聊天机器人之间的交流效率。此外,作者还

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!