繁体   English   中英

angularjs:如何在剑道模板中设置剑道颜色选择器的值?

[英]angularjs: How to set the value of a kendo color picker inside kendo template?

我的剑道网格具有以下rowTemplate:

<script id="gridTemplate" type="text/x-kendo-template">
<tr data-uid="#= uid #">
    <td>
        <input type="color" kendo-color-picker k-palette="controller.colors" value="'#=color#'" on-change="controller.changeColor()" />
    </td>
</tr>

我的问题是我想从dataItem.color属性设置颜色选择器的值。 使用上面的语法,我得到以下消息: The specified value "'#0000ff'" does not conform to the required format. The format is "#rrggbb" where rr, gg, bb are two-digit hexadecimal numbers. The specified value "'#0000ff'" does not conform to the required format. The format is "#rrggbb" where rr, gg, bb are two-digit hexadecimal numbers.

如果将其更改为value="#=color#" (不带单引号),则会得到:

Error: [$parse:lexerr] Lexer Error: Unexpected next character  at columns 0-    0 [#] in expression [#00ff00].
http://errors.angularjs.org/1.4.0/$parse/lexerr?p0=Unexpected%20next%20character%20&p1=s%200-0%20%5B%23%5D&p2=%2300ff00
Cause: <input type="color" kendo-color-picker="" k-palette="trend.colors" value="#00ff00" on-change="trend.changeColor()">
{anonymous}()@columns 0-0 [#] in expression [#00ff00].
{anonymous}() (http://errors.angularjs.org/1.4.0/)$parse/lexerr?p0=Unexpected%20next%20character%20&p1=s%200-0%20%5B%23%5D&p2=%2300ff00

我试图将模板移动到有角度的代码中并使用function(dataItem)但导致了相同的错误。 任何帮助都感激不尽。

尝试设置“值”字段时,我收到相同的错误。 相反,我尝试设置表示调色板的视图模型/ $ scope属性。

剑道拾色器控件

        <input kendo-color-picker ng-model="dashboardBuilder.templateOptions.titleBackgroundColor" k-palette="'websafe'" k-preview="false" k-input="true" k-opacity="true"/>

在控制器的load事件中,将调色板的属性设置为

 vm.templateOptions = {
            titleBackgroundColor: '#000000'
        };

这会将您的选择器默认为您选择的颜色。

暂无
暂无

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

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