Skip to content Skip to sidebar Skip to footer

Polymer 2.0 Call Child Event From Parent

I keep running into bad examples or outdated 1.0 docs regarding calling child event from the parent in Polymer 2.0. Essentially all I want to accomplish is triggering a child even

Solution 1:

Give an id to

<child-element id="childEl"></child-element>

And fire child element function at parent like:

this.$.childEl.childEvent();

Solution 2:

This is how my template of polymer 3.0 component looks like.

staticgettemplate() {
     return html`<my-componentid="myComponent" />
     `
 }

And now to call any method in my component class, I do it like this.

this.$.myComponent.myMethod();

Here myComponent after $ is the id of my-component.

Post a Comment for "Polymer 2.0 Call Child Event From Parent"