Last active
February 25, 2016 15:27
-
-
Save Alos/ea00c53a9fa841009f68 to your computer and use it in GitHub Desktop.
Polymer Behaviour Question
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link rel="import" href="../../bower_components/polymer/polymer.html"> | |
<link rel="import" href="../../bower_components/iron-selector/iron-selectable.html"> | |
<dom-module id="my-element"> | |
<template> | |
<style> | |
:host { | |
display: block; | |
} | |
</style> | |
<div>Hello from <span>{{items}}</span></div> | |
</template> | |
<script> | |
(function() { | |
'use strict'; | |
Polymer({ | |
is: 'my-element', | |
properties: { | |
//nothing to see here | |
}, | |
//by adding this behavior here it means that this element has the 'items' attribute among other things | |
behaviors: [Polymer.IronSelectableBehavior], | |
ready:function(){ | |
console.log(this.items);//my items should be here but no... nothing :( | |
} | |
}); | |
})(); | |
</script> | |
</dom-module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//somewhere else where I can inspect myarray and confirm that is has "things" in it | |
<my-element items="[[myarray]]" selected="0"></my-element> |
Hm it's interesting that you see an array at all and not just an undefined
if it truly is undefined...
Indeed! I sort of assumed the behavior would initialize the items array tho.
If it's bound to myArray I would think that it would since a binding is just shorthand for saying myElement.items = myArray
. Are you able to put together a jsbin to illustrate this? Maybe it's a timing issue
You can use bit.ly/polybin as a starter
Sorry, it took so long..work got in the way! Please have a look:
https://jsbin.com/kazide/edit?html,console,output
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On somewhere-else element:
$0.myarray
[Object, Object]
On my-element:
$0.items
[]