Afaq
Afaq

Reputation: 1155

Accessing properties of parent template in child template

I have created a polymer element which has a nested template. I want to access properties of parent template in the child template.

<dom-module id="gallery-content">
<template>
    <template is="dom-bind">
        <iron-ajax url="/getData" last-response={{data}} auto></iron-ajax>
        <table id="table-stencils">
            <tr>
                <td>
                    <p>{{contentType}}</p>
                    <hr>
                </td>
            </tr>
            <tr>
                <td>
                    <image-block description={{data.description}}
                                 lastmodified={{data.lastModified}}
                                 imagepath="../../images/11.jpg"></image-block>
                </td>
                <td>
                    <image-block description={{data.description}}
                                 lastmodified={{data.lastModified}}
                                 imagepath="../../images/12.jpg"></image-block>
                </td>
                <td>
                    <image-block description={{data.description}}
                                 lastmodified={{data.lastModified}}
                                 imagepath="../../images/13.jpg"></image-block>
                </td>
                <td>
                    <image-block description={{data.description}}
                                 lastmodified={{data.lastModified}}
                                 imagepath="../../images/14.jpg"></image-block>
                </td>
            </tr>
        </table>
    </template>
</template>
<script>
    Polymer({
        is: "gallery-content",
        properties:{
            contentType: {
                type:String,
                value:"Others"
            }
        }
    });
</script>

I am not able to access contentType property of the parent element. I am using another polyment() inside this gallery-content element.

Upvotes: 0

Views: 784

Answers (1)

a1626
a1626

Reputation: 2964

Here is a running plunkr of your element without dom-bind. Please note i've used a json as getData service and a temporary element for image-block

Upvotes: 1

Related Questions