Polymer: Can't Get This.__data__ Passing In From Host
I have a very simple project: app/ parent.html child.html index.html I try to pass data from parent to child and then get them within Polymer(): index.html
Solution 1:
You can pass the data via javascript interface, just add the following to your parent (x-comphost
) implementation:
Polymer({
is: "x-comphost",
ready: function(){
this.policies = ['Hospital', 'Dental', 'Travel'];
/* Query shadow DOM for the x-child element */var childEl = Polymer.dom(this.root).querySelector('x-child');
childEl.accessiblePolicies = this.policies;
}
});
Solution 2:
Configure Policies in properties object instead of ready cycle in parent and as per Parent attribute name make properties in child , mentioned in below code
Parent.html
Polymer({ is: "x-comphost",
properties :{
policies : {
type : Array,
value : ['Hospital', 'Dental', 'Travel']
}
},
ready: function(){
// this.policies = ['Hospital', 'Dental', 'Travel'];
}
});
Child.html
Polymer({ is: "x-child",
properties: {
accessiblePolicies : {
type : Array,
value : [] }
},
ready: function () {
console.log('thisData', this.accessiblePolicies);
}
});
Post a Comment for "Polymer: Can't Get This.__data__ Passing In From Host"