In this question the OP asked about how to avoid exposing private objets to the outside in a component. I’ve been googling around and can’t find a way to do the opposite. Say I have the component below and I want to access privateObj from either my web page or a parent component. How can it be done using JavaScript and the Polymer API?
<polymer-element name="animating-element">
<script>
var privateObj = {};
privateObj.internalState = 0;
//private static method
privateObject.setupState = function(polymerObject) {
if(polymerObject.stateExposedToOutside == /* some conditions */) {
privateObject.internalState = 1;
}
}
Polymer('animating-element', {
stateExposedToOutside: 0,
ready: function() {
privateObj.setupState(this);
this.animate();
},
animate: function() {
}
});
</script>
</polymer-element>
Aucun commentaire:
Enregistrer un commentaire