我正在使用带有angularjs的kendo ui编辑器,
<textarea kendo-editor
k-on-change="vm.bodyIsDirty = true"
k-options="vm.editorOptions"
ng-model="vm.myModel"
style="height: 320px;">
</textarea>
我可以从文档中看到相应的模型已经在模糊事件上更新了,我需要在keypress上更新它是否可能?
答案 0 :(得分:0)
使用k-on-keyup事件,其中'updateNgModel()'是控制器中$ scope中定义的函数
示例:
<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>