Rendering components in a core-list

61 views
Skip to first unread message

tcb

unread,
Oct 13, 2014, 8:26:53 AM10/13/14
to polym...@googlegroups.com
Hi,

I would like to have a core-list display some of my custom components. I have an itemList [myComponent1, myComponent2, ...] and I add and remove components- the components in itemList can be of slightly different kinds and while they are not very complicated, its easier to create them elsewhere and add/delete them to the list to be rendered as required.

But I can't figure out how to get core-list to actually render them- this doesn't work:
 
<template>
        <template bind repeat="{{item in itemList}}">
            {{item}}
        </template>
</template>


I have read this post and the FAQ, which offers a nice way to inject some html into another component: 

"Rendering Html"

<polymer-element name="p-html" attributes="html">
    <script>
        Polymer('p-html', {
            htmlChanged: function() {
                this.innerHTML = this.html;
            }
        });
    </script>
</polymer-element>

    <template>
        <template bind repeat="{{item in itemList}}">
            <p-html html="{{item}}"></p-html>
        </template>
    </template>


But its actually my own component I want as the list element.

The recent injectBoundHTML() looks interesting, but it doesn't seem to quite solve this problem.


From reading the docs, I think it might be possible to create a <ul></ul> in the template and manage adding/deleting my components manually. But the core-list is nice and saves me a lot of work if I can get it to do this for me.

It seems like this should be quite straightforward to do (if only I understand more about templates). Has anyone done something like this? If it is not possible, is there a simple reason why it can't be done?

many thanks,

Reply all
Reply to author
Forward
0 new messages