angularjskendo-uikendo-editor

Kendo UI Editor Events in Angularjs


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?


Solution

  • 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>