我使用的是带有angularjs的kendo ui编辑器,
<textarea kendo-editor
k-on-change="vm.bodyIsDirty = true"
k-options="vm.editorOptions"
ng-model="vm.myModel"
style="height: 320px;">
</textarea>我可以从文档中看到相应的模型在模糊事件中被更新,我需要在按键时更新它,这是可能的吗?
发布于 2017-06-27 23:05:49
使用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>https://stackoverflow.com/questions/37347801
复制相似问题