触发Kendo Editor小部件的onChange事件

时间:2015-04-23 06:35:26

标签: angularjs kendo-ui kendo-editor

假设我有以下kendo-editor:

<div kendo-editor ng-model="name" k-options="editorOptions"></div>

然后,我有以下editorOptions

function onChange(e) {
   alert("I am changing.");
}
$scope.editorOptions = { change: onChange };

如何在不使用普通jQuery选择的情况下触发onChange事件来访问实际的kendo-editor对象:

示例:$("#myEditor").kendoEditor().trigger("change")

1 个答案:

答案 0 :(得分:1)

您必须在当前范围(http://docs.telerik.com/kendo-ui/AngularJS/introduction#getting-widget-references)中定义控件引用,并且可以将事件定义为属性:

<div ng-app="app" ng-controller="MyCtrl">
  <div kendo-editor="kendoEditorControl" ng-model="name" k-options="editorOptions" k-on-change="onChange()"></div>
</div>
<script>
  angular.module("app", [ "kendo.directives" ]).controller("MyCtrl", function($scope) {
    $scope.onChange = function() {
     alert($scope.kendoEditorControl.value());
    };
  });
</script>