Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bind attribute replacement #1790

Closed
winhowes opened this issue Jun 8, 2015 · 2 comments
Closed

bind attribute replacement #1790

winhowes opened this issue Jun 8, 2015 · 2 comments

Comments

@winhowes
Copy link

winhowes commented Jun 8, 2015

Hi, I'm aware the bind attribute has been disabled on <template>s but after pouring through the docs on polymer-project.org, stackoverflow.com and the polymer source code I'm not sure how to port the same functionality to Polymer 1.0. As I understand it the bind attribute allows you to scope to properties inside of a template.

So with this code snippet I would expect name to become "test" (if bind was ported from Polymer 0.5), but I'm not sure how to apply this scoping in Polymer 1.0. I know I could just do {{data.name}} but unfortunately my use case is a bit more complex and that won't work. Could you please advise on how to achieve this? My element is supposed to be a file treeview, which either requires an indefinite number of dom-repeats or scoping like this.

<dom-module is="example-elem">
  <template>
      <template bind="{{data}}">
        <div>{{name}}</div>
      </template>
  </template>
</dom-module>

<script>
Polymer({

    is: 'example-elem',

    properties: {
      data: {
        type: Object,
        value: {
           name: "test"
        }
      }
    }
}
</script>
@euclid1990
Copy link

@winhowes
Do you want followings code 👎

<dom-module id="example-elem">
    <template>
        <span>[[ data.name ]]</span>
    </template>
</dom-module>

<script>
Polymer({
    is: 'example-elem',
    ready: function() {
        this.data.name = "Polymer";
    },
    properties: {
      data: {
        type: Object,
        value: {
           name: ""
        }
      }
    }
});
</script>

<template is="dom-bind">
    <example-elem data="{{ data }}"></example-elem>
</template>

@winhowes
Copy link
Author

I guess my broader question was if it was possible to do recursion, but I believe I have found an answer: https://stackoverflow.com/questions/30468581/polymer-recursive-template-binding/30469213#30469213. I'll close this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants