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

Demo to illustrate data binding inside generic element? #11

Open
veronicawwashington opened this issue Jul 6, 2015 · 5 comments
Open

Comments

@veronicawwashington
Copy link

Shouldn't the demo illustrate binding an <iron-meta> variable inside a generic custom element? That use case seems to better reflect the intended purpose of the <iron-meta> element.

Example: (maybe something like this...)

<dom-module id="custom-element">
  <style>...</style>
  <template>
    <iron-meta id="meta" key="info" value="foo/bar"></iron-meta>
    The <code>value</code> stored at <code>key="info"</code>
    is <code><span>{{test}}</span></code>.  
  </template>
</dom-module>
<script>
  (function() {
    Polymer({
      is: 'custom-element',
      properties: {
        test: String
      },
      ready: function() {
        this.test = this.$.meta.byKey("info");
      }
    });
  })();
</script>

I am just learning Polymer so I am probably just missing something or doing something dumb.

@veronicawwashington veronicawwashington changed the title Demo: Use Case Demo to reflect use case of variable insertion into generic element? Jul 6, 2015
@veronicawwashington veronicawwashington changed the title Demo to reflect use case of variable insertion into generic element? Demo to illustrate data binding within generic element? Jul 7, 2015
@veronicawwashington veronicawwashington changed the title Demo to illustrate data binding within generic element? Demo to illustrate data binding inside generic element? Jul 7, 2015
@akc42
Copy link

akc42 commented Oct 31, 2015

I've been playing with putting some tags on a page and using databinding. The trouble is, you can put data in using databinding, but you can't get it out again. I tried stepping through the code to find out why, and it never appears to write the value back to the value attribute, so although it has notify:true on it, the value is put into the meta data and that is as far as it goes.

Of course, as per the docs, you can imperatively query it in code.

I think one way of doing it might be to use <iron-meta-query key="[[binding]]", value="{{anotherbinding}}"> - if you change the key value, it then outputs the correct value for the new key - but it seems messy.

@akc42
Copy link

akc42 commented Nov 2, 2015

Having found that iron-meta did not appear to work with data binding, I have built my own version (akc-meta) that seems to work well with data binding. This keeps a list of query elements with a particular key in shared storage, so when the value changes on the input element, it sends a new value out to all the query elements in that list, writing it back to the value property. This has the notify:true flag, so gets passed into the data binding system.

See https://github.com/akc42/akc-meta

@albertolobrano
Copy link

you can use iron-meta to store the value you want to share and iron-meta-query to query it and bind to an object.

for instance: in one component you define

  <iron-meta key="user" value="{{user}}"></iron-meta>

in another component you can access it simply doing

<iron-meta-query key="user" value="{{_user}}"></iron-meta-query>

the user is {{_user.name}}

@notwaldorf
Copy link
Contributor

@veronicawwashington Would you be interested in sending a PR to update the demo? It would be much appreciated! 🍰

@safizn
Copy link

safizn commented Apr 26, 2016

2 way binding ! A feature still needed, I think for the lack of Global Polymer Attributes/Variables which support data binding.

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

No branches or pull requests

5 participants