0

polymer's template repeat次のような機能を使用して、カスタム サブ要素をローカル ストレージの値にバインドしようとしています。

<polymer-element name="aw-outerElement">
<template>
    <template repeat="{{group in grouplist}}">
        <aw-innerElement groupId="{{group.groupId}}" name="{{group.name}}" val="{{group.val}}"></aw-innerElement>
    </template>
</template>
<script>
Polymer('aw-outerElement', {
ready : function () {
    // Binding the project to the data-fields
    this.prj = au.app.prj;
    this.grouplist =  [ 
                    { groupId: 100, name: 'GroupName1', val: this.prj.ke.groupVal100},
                    { groupId: 200, name: 'GroupName2', val: this.prj.ke.groupVal200}

    ];
}
</script>

this.prj.ke.groupVal100上記のコードでは、データ バインディングを、属性を介しthis.prj.ke.groupVal200 て内部要素に渡そうとしています。これは、value 属性をたとえば に設定する必要があるカスタム要素です。value属性内のデータバインディング文字列 はなく、保存された初期値0のみが設定されるようです。内部要素でデータバインディングを作成する方法はありますか?aw-innerElementvalaw-innerElementpaper-inputthis.prj.ke.groupVal100this.prj.ke.groupVal100template repeat

私の内部要素は次のようになります。

<polymer-element name="aw-innerElement" attributes="groupId name val">
<template>
    <paper-input type="number" floatingLabel label="{{groupId}} {{name}}" value="{{val}}" error="{{i18nnrerror}}"></paper-input>
</template>
<script>
Polymer('aw-innerElement', {
publish: {
     groupId: 0,
     name: '',
     val: 0
},

ready : function () {
    // Binding the project to the data-fields
    this.prj = au.app.prj;
    ...

}
</script>

上でわかるようにvalue="{{val}}"、私の innerElement は と に設定する必要がthis.prj.ke.groupVal100ありthis.prj.ke.groupVal200ます。

前もって感謝します!

4

3 に答える 3

0

私はポリマーが初めてなので、私の答えは正しくないかもしれません。しかし、私はあなたがやろうとしているようなことをしました。

ここに私のコードのサンプルがあります

あなたの問題は、テンプレートでバインドを使用しなかったことだと思います

<template bind="{{grouplist}}">
    <template repeat="{{group in grouplist}}">
    </template>
</template>


<script>
Polymer('aw-outerElement', {
ready : function () {
    // Binding the project to the data-fields
    this.prj = au.app.prj;
    this.grouplist =  [ 
                    { groupId: 100, name: 'GroupName1', val: this.prj.ke.groupVal100},
                    { groupId: 200, name: 'GroupName2', val: this.prj.ke.groupVal200}
    ];
}
</script>
于 2014-08-20T17:13:50.343 に答える