简体   繁体   English

如何将k-ng-model初始化为Kendo模板?

[英]How to initialize k-ng-model to Kendo template?

I use kendo UI with AngularJS. 我在AngularJS中使用kendo UI

I tried something like this in the html directly: 我直接在html中尝试了类似的方法:

 <div id="item-settings">
    <label>BACKGROUND:</label><div style="display: block" id="colorPalette1" kendo-color-palette k-ng-model="colorPaletteData" k-opacity="true"></div>
</div>

and somthing like this in my angular controller: 在我的角度控制器中是这样的:

 $scope.$watch('colorPaletteData', function (newValue, oldValue) {
        changeColor(newValue);
    })

It work's fine. 很好

But I would like to add the html stuff not directly to the html but with javascript like this: 但是我想将html内容不直接添加到html中,而是使用如下javascript:

   $("#item-settings").kendoToolBar({
            resizable: false,
            items: [

                { template: '<label>BACKGROUND:</label><div style="display: block"  id="colorPalette1" kendo-color-palette k-ng-model="colorPaletteData" k-opacity="true"></div>' },

            ]
        });


    $("#colorPalette1").kendoColorPalette({
            palette: "basic",
            value: "#ffffff"

        });

But now the $scope.$watch() function doesn't watch the k-ng-model="colorPaletteData" 但是现在$scope.$watch()函数不再监视k-ng-model="colorPaletteData"

How can I fix this? 我怎样才能解决这个问题?

You should not initialize the widget using jQuery, and you need to use the Kendo UI Directives. 您不应该使用jQuery初始化窗口小部件,而需要使用Kendo UI指令。 As currently the template is not evaluated against the scope. 目前,尚未根据范围评估模板。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM