module - AngularJS ckEditor, multiple instances -


i have app drag , drop functionality. also, possible drop ckeditor in it.

how possible create new instance of ckeditor, problem have instances have same "ng-model".

i saw answer "ng-repeat" here: jsfiddle.net/thesharpieone/cptr7/ app not have such repeater.

thank you

had similar problem, don't know if can you, solved problem.

var app = angular.module('app', []);    app.directive('ckeditor', [function () {      return {          require: '?ngmodel',          link: function ($scope, elm, attr, ngmodel) {                var ck = ckeditor.replace(elm[0]);                ck.on('pastestate', function () {                  $scope.$apply(function () {                      ngmodel.$setviewvalue(ck.getdata());                  });              });                ngmodel.$render = function (value) {                  ck.setdata(ngmodel.$modelvalue);              };          }      };  }])    function myctrl($scope){      $scope.ckeditors = [];      $scope.post = 0;      $scope.addeditor = function(id){          $scope.ckeditors.pop();          $scope.post=id;          var rand = ""+(math.random() * 10000);          $scope.ckeditors.push({value:rand});      }  }
<script src="http://ckeditor.com/apps/ckeditor/4.2/ckeditor.js"></script>  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>  <div data-ng-app="app" data-ng-controller="myctrl">        <h3>post1:</h3>      <div ng-repeat="editor in ckeditors">      <textarea ng-if="post==1" data-ng-model="editor.value" data-ck-editor></textarea>      <br />      </div>      <button ng-click="addeditor(1)">new editor</button>    <h3>post2:</h3>      <div ng-repeat="editor in ckeditors" >      <textarea ng-if="post==2" data-ng-model="editor.value" data-ck-editor></textarea>      <br />      </div>      <button ng-click="addeditor(2)">new editor</button>

http://jsfiddle.net/paulosegundo/mrlz8eba/


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -