1
ck editor text area
<textarea cols="100" id="editor1" name="editor1" rows="50" data-ng-model="report.reportlist">

</textarea>
<div>{{ report.reportlist }}</div>

div内で値を取得していますが、ckエディターでは取得していません

私のコントローラー

$scope.report.reportlist = data ;

data = <p><h1>PRO/AH/EDR> African swine fever - Belarus (03): (HR) 1st rep, OIE, RFI</h1><br/><br/><p>African Swine Fever &mdash; Worldwide/Unknown<br/></p>

CK エディターに表示されない理由がわかりません。私はAngular jsを使用しています

4

1 に答える 1

2

CKEditor 内のコンテンツが実際には textarea 自体にない (textarea 要素が非表示になる) ため、機能しません。スコープ変数と CKeditor の同期を保つには、CKEditor イベントをリッスンし、それに応じてスコープ変数を更新する必要があります。
ここで簡単なデモを作成しました: http://jsbin.com/iMoQuPe/2/edit

HTML:

<!DOCTYPE html>
<html ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <div ng-controller="CkCtrl">
    <textarea name="editor" id="" cols="30" rows="10" ng-model="editorData"></textarea>
    <pre>
      {{ editorData }}
    </pre>
  </div>
  <script src="http://cdnjs.cloudflare.com/ajax/libs/ckeditor/4.0.1/ckeditor.js"></script>
  <script>
    CKEDITOR.replace( 'editor' );
  </script>
</body>
</html>

JavaScript:

function CkCtrl($scope) {
  // Load initial data, doesn't matter where this comes from. Could be a service
  $scope.editorData = '<h1>This is the initial data.</h1>';

  var editor = CKEDITOR.instances.editor;

  // When data changes inside the CKEditor instance, update the scope variable
  editor.on('instanceReady', function (e) {
    this.document.on("keyup", function () {
      $scope.$apply(function () {
        $scope.editorData = editor.getData();
      });
    });
  });
}
于 2013-09-30T09:54:51.987 に答える