How to use ckeditor in angular JS application?

I am new to angularJS and I need to use ckeditor for the text field in my application.

Before I tried it in an angular app, I made the web page only "html only". I created my ckeditor package here and added the necessary tags (as shown below) and it works like a charm.

<!DOCTYPE HTML>
<html>
<head>
        <title>CKEditor test page</title>
        <meta charset="utf-8">
</head>
<body>
    <script src='./ckeditor/ckeditor.js'></script>
        <div>
          <form>
              <label>Text input</label>
              <textarea name="text" id='editor1' class="ckeditor"></textarea>
              <input type="submit" method="GET">
          </form>
          <script>
              CKEDITOR.replace('editor1');
          </script>
        </div>
    </body>
</html>

Now I'm trying to use ckeditor for one text area of ​​one of the tpl “views” for my angular project, and I cannot get it to work :( Here is the contents of the tpl.html view:

<script src='./ckeditor/ckeditor.js'></script>

<div class="container">
    <div class="page-header">
        <h2>Title</h2>
    </div>
    <form role="form" class="input_form">
        <accordion>
            <accordion-group heading="Add content" is-open="false">
                <div class="form-group">
                    <label class="control-label">TEXT INPUT</label>
                    <textarea id='test' class="form-control"  rows="3" ng-model="data.body"
                              placeholder="Write your text here!"/></textarea>
                </div>
            </accordion-group>
        </accordion>
        <div class="text-right">
            <a ng-click="submitText()" class="btn btn-primary">Send text</a>
        </div>
    </form>
</div>

ckeditor ? ​​- ? http://github.com/esvit/ng-ckeditor http://github.com/lemonde/angular-ckeditor

:)

+4
3

https://github.com/lemonde/angular-ckeditor. 1-3 README.md, ...

  • angular -ckeditor: git clone -depth=50 https://github.com/lemonde/angular-ckeditor
  • resoureces bower: bower install angular-ckeditor
  • (. README.md)
  • js html, :
<script type="text/javascript" src="/angular-ckeditor/angular-ckeditor.min.js"></script>
<script type="text/javascript" src="/angular-ckeditor/bower_components/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="/yourApp.js"></script>
<script type="text/javascript" src="/yourController.js"></script>
  1. html, . html, - :

data-ng-init="content='this is a text with &lt;a href=&quot;http://localhost/whatever.html&quot; target=&quot;_blank&quot;&gt;an embedded Link&lt;/a&gt;'" contenteditable="true" ready="onReady()">

( $http).

0

angular (https://github.com/jziggas/ng-ck) ckeditor, . angular 1.6 CKEditor 4.6. ckeditor, , <ng-ck ng-model="content"></ng-ck>. , ckeditor.

0

:

(function () {
    'use strict';

    angular
        .module('app')
        .directive('ckeditor', Directive);

    function Directive($rootScope) {
        return {
            require: 'ngModel',
            link: function (scope, element, attr, ngModel) {
                var editorOptions;
                if (attr.ckeditor === 'minimal') {
                    // minimal editor
                    editorOptions = {
                        height: 100,
                        toolbar: [
                            { name: 'basic', items: ['Bold', 'Italic', 'Underline'] },
                            { name: 'links', items: ['Link', 'Unlink'] },
                            { name: 'tools', items: ['Maximize'] },
                            { name: 'document', items: ['Source'] },
                        ],
                        removePlugins: 'elementspath',
                        resize_enabled: false
                    };
                } else {
                    // regular editor
                    editorOptions = {
                        filebrowserImageUploadUrl: $rootScope.globals.apiUrl + '/upload',
                        removeButtons: 'About,Form,Checkbox,Radio,TextField,Textarea,Select,Button,ImageButton,HiddenField,Save,CreateDiv,Language,BidiLtr,BidiRtl,Flash,Iframe,addFile,Styles',
                        extraPlugins: 'simpleuploads,imagesfromword'
                    };
                }

                // enable ckeditor
                var ckeditor = element.ckeditor(editorOptions);

                // update ngModel on change
                ckeditor.editor.on('change', function () {
                    ngModel.$setViewValue(this.getData());
                });
            }
        };
    }
})();

:

<!-- regular wysiwyg editor -->
<textarea ng-model="vm.article.Body" ckeditor></textarea>

<!-- minimal wysiwyg editor -->
<textarea ng-model="vm.article.Body" ckeditor="minimal"></textarea>
0

All Articles