1

假设我有以下剑道编辑器:

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

然后,我有以下内容editorOptions

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

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

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

4

1 回答 1

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>
于 2015-04-23T07:23:27.907 回答