簡體   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