krial
krial

Reputation: 842

Bind data to content element in Polymer

I wanted to ask if it is possible to bind data to the element and access it later inside the actual content. Here is an example: I want to create a list component, however let the user define how to render every entry. Here is my current code:

List Element:

<template repeat="{{item in items}}">
  <content></content>
</template>

User using it:

<ak-list items="{{items}}">
  {{item.name}}
</ak-list>

However, this does not work

Upvotes: 2

Views: 587

Answers (1)

saurshaz
saurshaz

Reputation: 509

I suppose - you won't get access to data model from inside HTML portion in the web components.

You need to be defining the data in the template. I guess you might be already aware of that.

http://jsbin.com/yadazo/1/edit?html,output

A bin with how it could work.

Also, you can control the presentation by passing in an additional data which you can then use in your template -

An example of the same is below. -

http://jsbin.com/yateka/1/edit?html,output

both the list and how you want it can be supplied and then template created with that stuff.

Upvotes: 2

Related Questions