Kendo UI Editor Events in Angularjs

2019-07-12 20:24发布

How do I get the event properties from the events in Kendo UI Editor?

I've taken the code from the KendoDemo download and edited it a bit to get the events for k-on-change and k-on-keydown. The events are described here.

<div id="example" ng-app="KendoDemos">
    <div ng-controller="MyCtrl">
            <textarea kendo-editor k-ng-model="html" k-on-keydown="keydown(e)" k-on-change="onChange(e)"></textarea>
    </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.onChange = function(e){
            console.log('onchange');
            console.log(e);
          };
          $scope.keydown = function(e){
            console.log('keydown');
            console.log(e);
          }
      })
</script>

The output in the event methods onChange and keyDown don't give me the e property described in the documentation.

What am I missing?

1条回答
冷血范
2楼-- · 2019-07-12 21:08

Rubber duck debugging effect kicking in...

Found what I was looking for, add all options using k-options.

<div id="example" ng-app="KendoDemos">
    <div ng-controller="MyCtrl">
            <textarea kendo-editor k-ng-model="html" k-options="options"></textarea>
    </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.options = {
              change: function(e){console.log(e);},
              keydown: function(e){console.log(e);}
          };
      })
</script>
查看更多
登录 后发表回答