2016-06-23 5 views
0

중첩 템플릿이있는 폴리머 요소를 만들었습니다. 자식 템플릿에서 부모 템플릿의 속성에 액세스하려고합니다.하위 템플릿의 상위 템플릿 속성 액세스

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

나는 부모 요소의 contentType 속성에 액세스 할 수 없습니다입니다. 이 gallery-content 요소 내에 또 다른 polyment()를 사용하고 있습니다.

+0

왜 DOM- 바인드 템플릿 안에 있습니까? dom-bind는 새로운 요소를 만들지 않고 일반 html로 폴리머 객체를 만드는 데 사용합니다. – a1626

+0

@ a1626 : 하위 템플릿 안에 다른 폴리머 요소가 있고 데이터 바인딩에 필요한 호출이 입니다. – Afaq

+1

나는 새로운 폴리머 요소를 다른 폴리머 안에 어떻게 만들 수 있을지 약간 혼란 스럽다. 왜 그걸 쓸거야? 아약스 호출로 무엇을 가져 오는거야? 어쨌든 dom-bind 사용법은 사용자 정의 요소를 만들지 않고 html로부터 요소를 생성하는 데 사용한다고 말합니다. – a1626

답변

1

여기에 dom-bind이없는 요소의 plunkr이 실행 중입니다. 제발 json을 getData 서비스와 임시 요소로 사용했습니다. image-block

관련 문제