โพลีเมอร์ ประเมินองค์ประกอบตามวัตถุ

ฉันกำลังใช้ตัวอย่างไทล์จากองค์ประกอบนีออนโพลีเมอร์ - และฉันกำลังพยายามทำให้ไทล์ที่ขยายแต่ละอันมีเอกลักษณ์เฉพาะตัว ความพยายามครั้งแรกของฉันในการทำเช่นนี้คือการส่งสตริงเข้ากับรายการกริดเช่น

 {
      value: 1,
      color: 'blue',
      template: 'slide-1'
 }

และให้ประเมินองค์ประกอบนั้นเมื่อแสดงผลในองค์ประกอบใหม่ในลักษณะนี้ (นี่คือเทมเพลตการ์ดนั่นเอง)

<template>

<div id="fixed" class$="[[_computeFixedBackgroundClass(color)]]"></div>

<div id="card" class$="[[_computeCardClass(color)]]">
  <[[item.template]]></[[item.template]]>
</div>

This does not work - however I am wondering if there is some way to do this so I can load custom elements for the content of each card. For reference -https://elements.polymer-project.org/elements/neon-animation?view=demo:demo/index.html&active=neon-animated-pages , it is the grid example and I am trying to replace the content of each card once it is clicked on ( the fullsize-page-with-card.html, here is all the html for it - https://github.com/PolymerElements/neon-animation/tree/master/demo/grid ). Is this the wrong way of approaching this? Or maybe I have some syntax wrong here. Thanks!

แก้ไข : โอเค งั้นผมส่งผ่านได้เลยถ้าผมเพิ่มเข้าไปในการคลิกเพื่อเปิดการ์ดแบบนั้น

   scope._onTileClick = function(event) {
        this.$['fullsize-card'].color = event.detail.data.color;
        this.$['fullsize-card'].template = event.detail.data.template;
        this.$.pages.selected = 1;
    };

และในคุณสมบัติของการ์ดเช่นนั้น

 template: {
    type: String
  },

ดังนั้นฉันสามารถประเมินเป็น [[template]] ได้ - คำถามยังคงมีอยู่ว่าจะเรียกองค์ประกอบที่กำหนดเอง (แบบไดนามิก) โดยใช้สตริงนี้ได้อย่างไร ฉันสามารถส่งคุณสมบัติสองสามรายการและกรอกการ์ดหรือแบบฟอร์มเพื่อให้คุณสมบัติเหล่านี้ไม่ซ้ำกัน แต่ฉันคิดว่าฉันจะมีอิสระในการสร้างสรรค์มากขึ้นหากสามารถเรียกองค์ประกอบที่กำหนดเองภายในการ์ดแต่ละใบได้


person ajmajmajma    schedule 26.08.2015    source แหล่งที่มา


คำตอบ (1)


ฉันมีองค์ประกอบที่อนุญาตให้ใช้เทมเพลตอ้างอิง ยังมีอีกสองสามอย่างที่นั่น แต่อันนี้ยังอนุญาตให้การเชื่อมโยงข้อมูลทำงานได้: https://github.com/Trakkasure/dom-bindref

person Brandon    schedule 26.08.2015