I\'m working on a Polymer app, which is pulling data from a RESTful API and using it to construct the interface. A specific area I\'m stuck on conceptually is the implementa
@Zreptil has asked for an example above, and since I had to experiment with this anyway I built one based on Tim Stewart's answer and the Polymer documentation.
Complete Example: http://jsbin.com/figizaxihe/1/edit?html,output
I had some troubles with dashes in the id (id="global-variable"
) so I also added an example for that.
The element definition
Use it inside a polymer element
Output-Element
First Name: {{$.globalvars.data.firstName}}
Use it outside a polymer element
First Name in Title: {{$.topglobals.data.firstName}}
Pay attention with dashes/hyphens
and since that took me a while to realize - dashes are not directly supported...
This does not work: {{$.global-variables.data.firstName}}
Correct syntax: {{$['global-variables'].data.firstName}}
Polymer 1.0
See Polymer 1.0 Global Variables for a polymer 1.0 solution if interested.