如何从角度$ scope更新Kendo编辑器

时间:2015-04-10 12:27:16

标签: javascript angularjs kendo-ui

我有以下代码。

HTML

<textarea ng-bind-html="html" style="height:440px" kendo-editor k-   options="editorOptions"></textarea>

JS

angular.module('SplashApp', ['ngRoute', 'kendo.directives', 'ngSanitize'])
    .controller("MainController", function ($scope, $location, $route, $http, $sce) {
        $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.html进行更改。但是,如果我从javascript更改$ scope.html,编辑器的内容不会更改。我如何实现这一目标?

1 个答案:

答案 0 :(得分:0)

嗯,我已经创建了一个道场,并可以相应地重现你的应用程序。并创建了一个按钮来更改控制器中的html。

 angular.module('SplashApp', ['kendo.directives', 'ngSanitize'])
        .controller("MainController", function ($scope) {
            $scope.html = "<h1>Kenessssdo 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.addHtml = function(){
                                    $scope.html+= "<br>ahahahahhahah";
            };
    });

Dojo

一切都很好。你的语法是否正确?