Hi Kelly, core-localstorage retstores the value for me:
http://jsbin.com/qumovesuruki/1/edit

core-localstorage won't be able to see your global variable, itemsApiURL.
You're creating that on the window object in your example. Instead, you
need to populate the value property in the auto-binding template:

<template id="t" is="auto-binding">
  <core-localstorage name="itemsApiURL"
value="{{value}}"></core-localstorage>
  <my-datasource-element url="{{value}}"
items="{{items}}"><my-datasource-element>
</template>

<script>
var t = document.querySelector('#t');
t.value = "http://server:port/api/items";;
</script>'

See
http://www.polymer-project.org/docs/polymer/databinding-advanced.html#autobinding


On Fri, Sep 12, 2014 at 11:59 AM, Kelly St. John <[email protected]> wrote:

> In the following stripped-down code example, shouldn't the
> core-localstorage element load the value of the global js variable
> `itemsApiURL' into {{value}}, so that it is passed into
> my-datasource-element when that custom element is prepared?  Or is the
> purpose of core-localstorage limited to writing values to localstorage?
>  Currently, as is, {{value}} is undefined on my-datasource-element's
> ready() event, despite it existing as a global variable (ideally set in an
> external js config file, not included in head as shown here).  I'm
> definitely not doing something right...perhaps my lack of comfort with js,
> or some sort of scoping/sequence of events issue.
>
> Maybe there is an entirely better way to configure polymer app-wide
> variables/constants, so that values can be easily used my all of the
> applications elements, or at least passed around as element attributes via
> 2 way databinding?  That is really the more important question here I
> think...but either way I'm still confused as to how core-localstorage is
> meant to operate.
>
> <html>
> <head>
>      <script>
>           this.itemsApiURL = "http://server:port/api/items";;
>      </script>
>
>      <link rel="import" href="./components/platform/platform.js">
>      <link rel="import" href=
> "./components/core-localstorage/core-localstorage.html">
> </head>
>
> <body fullbleed unresolved>
>
>      <template is="auto-binding">
>           <core-localstorage name="itemsApiURL" value="{{value}}"
> ></core-localstorage>
>
>           <my-datasource-element url="{{value}}" items="{{items}}"
> ><my-datasource-element>
>      </template>
>
> </body>
> </html>
>
>  Follow Polymer on Google+: plus.google.com/107187849809354688692
> ---
> You received this message because you are subscribed to the Google Groups
> "Polymer" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/polymer-dev/7b9cb50e-fad1-468b-aa65-6c0d966cfc58%40googlegroups.com
> <https://groups.google.com/d/msgid/polymer-dev/7b9cb50e-fad1-468b-aa65-6c0d966cfc58%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

Follow Polymer on Google+: plus.google.com/107187849809354688692
--- 
You received this message because you are subscribed to the Google Groups 
"Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/polymer-dev/CACGqRCAcGcocfdi-bQGV%2BytMFKkZcHGEBG7Pa9v%3DOY8f-8HTNA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to