首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在按键时更改kendo ui编辑器

在按键时更改kendo ui编辑器
EN

Stack Overflow用户
提问于 2016-05-20 21:20:00
回答 1查看 1.1K关注 0票数 0

我使用的是带有angularjs的kendo ui编辑器,

代码语言:javascript
复制
<textarea kendo-editor
    k-on-change="vm.bodyIsDirty = true"
    k-options="vm.editorOptions" 
    ng-model="vm.myModel"
    style="height: 320px;">
</textarea>

我可以从文档中看到相应的模型在模糊事件中被更新,我需要在按键时更新它,这是可能的吗?

EN

回答 1

Stack Overflow用户

发布于 2017-06-27 23:05:49

使用k-on-keyup事件,其中'updateNgModel()‘是在控制器的$scope中定义的函数

示例:

代码语言:javascript
复制
<div id="example" ng-app="KendoDemos">
    <div ng-controller="MyCtrl">
            <textarea kendo-editor id="editor" k-on-keyup="updateNgModel()" k-ng-model="html"></textarea>

        <div class="box wide">
            <textarea ng-bind-html="html" style="width: 100%; height: 5em"></textarea>
        </div>
    </div>
</div>

<script>
  angular.module("KendoDemos", [ "kendo.directives", "ngSanitize" ])
      .controller("MyCtrl", function($scope){
          $scope.html = "<h1>Kendo Editor</h1>\n\n" +
          "<p>Note that 'change' is triggered when the editor loses focus.\n" +
              "<br /> That's when the Angular scope gets updated.</p>";

           $scope.updateNgModel= function() {
               $scope.html = $("#editor").data("kendoEditor").value();
           }
      })
</script>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37347801

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档