【问题标题】:angularjs: How to set the value of a kendo color picker inside kendo template?angularjs:如何在剑道模板中设置剑道颜色选择器的值?
【发布时间】:2015-11-06 09:15:00
【问题描述】:

我的剑道网格有以下 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.

如果我将其更改为 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),但结果相同。任何帮助将不胜感激。

【问题讨论】:

    标签: javascript angularjs kendo-ui kendo-template


    【解决方案1】:

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

    剑道拾色器控件

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

    在控制器的加载事件中设置调色板的属性

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

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

    【讨论】:

      猜你喜欢
      • 2017-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-05
      • 1970-01-01
      • 2016-08-13
      相关资源
      最近更新 更多