I have seen examples of passing a function from a parent lit-element to a child one like here - https://medium.com/@westbrook/litelement-to-do-app-1e08a31707a4
But I want the users of my element, not to be forced to create a wrapper element to use my element.
For example, my element is a dialog that computes some value.
I was hoping I could do something like this (html using my element):
<script>
function latLongResult(lat,long)
{
console.log("resulting lat long called");
}
</script>
<lat-long-chooser id="latLongDialog" resultingLatLong=${latLongResult(lat,long)}></lat-long-chooser>
And then in my element:
export class LatLongChooser extends LitElement {
static get properties() {
return {
latDecimalDegrees: Number,
longDecimalDegrees: Number,
resultingLatLong: {
type: Function,
}
};
}
saveConvertedValues() {
console.log("save other values called");
this.resultingLatLong(this.latDecimalDegrees,this.longDecimalDegrees)
}
When I try this, I get JavaScript errors.