Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8415457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:27:10+00:00 2026-06-10T01:27:10+00:00

I want to bind CKEditor text to ng-model text. My View: <form name="postForm" method="POST"

  • 0

I want to bind CKEditor text to ng-model text. My View:

    <form name="postForm" method="POST" ng-submit="submit()" csrf-tokenized class="form-horizontal">
  

    <fieldset>
    <legend>Post to: </legend>
    <div class="control-group">
      <label class="control-label">Text input</label>
      <div class="controls">
        <div class="textarea-wrapper">
          <textarea id="ck_editor" name="text" ng-model="text" class="fullwidth"></textarea>
        </div>
        <p class="help-block">Supporting help text</p>
      </div>
    </div>

    <div class="form-actions">
      <button type="submit" class="btn btn-primary">Post</button>
      <button class="btn">Cancel</button>
      <button class="btn" onclick="alert(ckglobal.getDate())">Cancel123</button>
    </div>
  </fieldset>
</form>

controller

      function PostFormCtrl($scope, $element, $attrs, $transclude, $http, $rootScope) {
      $scope.form = $element.find("form");
      $scope.text = "";
    
      $scope.submit = function() {
          $http.post($scope.url, $scope.form.toJSON()).
          success(function(data, status, headers, config) {
                  $rootScope.$broadcast("newpost");
                  $scope.form[0].reset();
              });
      };
    
      $scope.alert1 = function(msg) {
          var sval = $element.find("ckglobal");
          //$('.jquery_ckeditor').ckeditor(ckeditor);                                                                                                                      
          alert(sval);
      };
    }
    PostFormCtrl.$inject = ["$scope", "$element", "$attrs", "$transclude", "$http", "$rootScope"];

I want to set CKEditor value in $scope.text at the time of form submit.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T01:27:11+00:00Added an answer on June 10, 2026 at 1:27 am

    CKEditor does not update textarea while typing, so you need to take care of it.

    Here’s a directive that will make ng-model binding work with CK:

    angular.module('ck', []).directive('ckEditor', function() {
      return {
        require: '?ngModel',
        link: function(scope, elm, attr, ngModel) {
          var ck = CKEDITOR.replace(elm[0]);
    
          if (!ngModel) return;
    
          ck.on('pasteState', function() {
            scope.$apply(function() {
              ngModel.$setViewValue(ck.getData());
            });
          });
    
          ngModel.$render = function(value) {
            ck.setData(ngModel.$viewValue);
          };
        }
      };
    });
    

    In html, just use:

    <textarea ck-editor ng-model="value"></textarea>
    

    The previous code will update ng-model on every change.

    If you only want to update binding on save, override “save” plugin, to not do anything but fire “save” event.

    // modified ckeditor/plugins/save/plugin.js
    CKEDITOR.plugins.registered['save'] = {
      init: function(editor) {
        var command = editor.addCommand('save', {
          modes: {wysiwyg: 1, source: 1},
          readOnly: 1,
          exec: function(editor) {
            editor.fire('save');
          }
        });
    
        editor.ui.addButton('Save', {
          label : editor.lang.save,
          command : 'save'
        });
      }
    };
    

    And then, use this event inside the directive:

    angular.module('ck', []).directive('ckEditor', function() {
      return {
        require: '?ngModel',
        link: function(scope, elm, attr, ngModel) {
          var ck = CKEDITOR.replace(elm[0]);
    
          if (!ngModel) return;
    
          ck.on('save', function() {
            scope.$apply(function() {
              ngModel.$setViewValue(ck.getData());
            });
          });
        }
      };
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to bind a string value to a text box but only if
I want to bind the user score to a text box on the windows
I want to bind datagrid view column visibility with a property of class. I
I want to bind a textblock text to a property of a static class.
I want to bind a combox with my entity model via domain services. My
i want to bind a name into a textview in android if it's in
I want to bind combobox to value only and distinct name .But I get
I want to bind the variables in a query like this: SELECT people.name, conf.id
I want to bind a button's width to some textbox's text value, although I
I want to bind checkScroll() to the view PhotoListView so that I can call

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.