Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在AngularJS控制器中获取TinyMCE文本内容_Angularjs_Tinymce_Angular Ui - Fatal编程技术网

在AngularJS控制器中获取TinyMCE文本内容

在AngularJS控制器中获取TinyMCE文本内容,angularjs,tinymce,angular-ui,Angularjs,Tinymce,Angular Ui,我正在请求angularJS,我想要的是提交一个带有tinymce ui文本区域的表单,并提交HTML内容和文本内容 现在我的tinyMce文本区正在工作 我得到我想要的。 我只是不知道如何在我的控制器中检索它 如果不使用消毒功能,我怎么做? 谢谢。您可以使用init_instance_回调在活动tinymce编辑器中为KeyUp、ExecCommand和SetContent附加事件侦听器,并在触发这些事件时绑定$scope变量。如果您检查ui tinymce指令源代码,您将看到这些事件用于更新

我正在请求angularJS,我想要的是提交一个带有tinymce ui文本区域的表单,并提交HTML内容和文本内容

现在我的tinyMce文本区正在工作

我得到我想要的。 我只是不知道如何在我的控制器中检索它

如果不使用消毒功能,我怎么做?
谢谢。

您可以使用
init_instance_回调
在活动tinymce
编辑器
中为
KeyUp
ExecCommand
SetContent
附加事件侦听器,并在触发这些事件时绑定
$scope
变量。如果您检查
ui tinymce
指令源代码,您将看到这些事件用于更新模型

JAVASCRIPT

$scope.tinymceOptions = {
        resize: false,
        width: 400,  // I *think* its a number and not '400' string
        height: 300,
        plugins: 'textcolor link',
        toolbar: "undo redo styleselect bold italic forecolor backcolor",
        menu : { // this is the complete default configuration
            edit   : {title : 'Edit'  , items : 'undo redo | cut copy paste pastetext | selectall'},
            insert : {title : 'Insert', items : 'link media | template hr'},
            format : {title : 'Format', items : 'bold italic underline strikethrough superscript subscript | formats | removeformat'},
        },

        init_instance_callback: function(editor) {
          var textContentTrigger = function() {
            $scope.textContent = editor.getBody().textContent;
            $scope.$apply();
          };

          editor.on('KeyUp', textContentTrigger);
          editor.on('ExecCommand', textContentTrigger);
          editor.on('SetContent', function(e) {
            if(!e.initial)
              textContentTrigger();
          });
        }
    };
HTML

<textarea>{{textContent}}</textarea>
{{textContent}

它通过您设置的
ng型号
绑定到
$scope.user.commentaireValue
。谢谢!它就像一个符咒:)以防万一,它可以帮助我正在寻找editor.getContent({format:'text'})的人;以便使用原始文本检索换行符。
   app.controller('UserCreationCtrl', ['$scope', 'UsersFactory', '$location',
     function ($scope, UsersFactory, $location) {
    // callback for ng-click 'createNewUser':
    $scope.createNewUser = function () {
        UsersFactory.create($scope.user);
        $location.path('/user-list');
    };
    $scope.options=[
        {name:'black', shade:'dark'},
        {name:'white', shade:'light'},
        {name:'red', shade:'dark'},
        {name:'blue', shade:'dark'},
        {name:'yellow', shade:'light'}
    ];
    $scope.correctlySelected = $scope.options[1];
    $scope.tinymceOptions = {
        resize: false,
        width: 400,  // I *think* its a number and not '400' string
        height: 300,
        plugins: 'textcolor link',
        toolbar: "undo redo styleselect bold italic forecolor backcolor",
        menu : { // this is the complete default configuration
            edit   : {title : 'Edit'  , items : 'undo redo | cut copy paste pastetext | selectall'},
            insert : {title : 'Insert', items : 'link media | template hr'},
            format : {title : 'Format', items : 'bold italic underline strikethrough superscript subscript | formats | removeformat'},
        }
    };
    //tinyMCE.get('tinymce1').getBody().textContent;
}]);
$scope.tinymceOptions = {
        resize: false,
        width: 400,  // I *think* its a number and not '400' string
        height: 300,
        plugins: 'textcolor link',
        toolbar: "undo redo styleselect bold italic forecolor backcolor",
        menu : { // this is the complete default configuration
            edit   : {title : 'Edit'  , items : 'undo redo | cut copy paste pastetext | selectall'},
            insert : {title : 'Insert', items : 'link media | template hr'},
            format : {title : 'Format', items : 'bold italic underline strikethrough superscript subscript | formats | removeformat'},
        },

        init_instance_callback: function(editor) {
          var textContentTrigger = function() {
            $scope.textContent = editor.getBody().textContent;
            $scope.$apply();
          };

          editor.on('KeyUp', textContentTrigger);
          editor.on('ExecCommand', textContentTrigger);
          editor.on('SetContent', function(e) {
            if(!e.initial)
              textContentTrigger();
          });
        }
    };
<textarea>{{textContent}}</textarea>