I have a created a small web component with the help of this article using angular element which includes @Input and @Output.
I am able to pass data to @Input property but listening to the @Output event is making me crazy as I am unable to figure out how to read data from the callback event parameter.
//Emitting the boolean data
likeEvent() {
this.likeNotify.emit(true);
}
And in pure javascript I am listening to likeNotify event like this:
const el = document.querySelector('facebook-card');
el.addEventListener('likeNotify', e => {
console.log(e.currentTarget.data); // Not working
});
So How can I retrieve true/false value from e object passed from emitter?
selectorof the emitting component in your html somewhere? You can hook into the output there. for example:<my-component (likeNotify)="callFunction()"></my-component>console.log(e)and it should logtrueevent.detailthat will contain the event dataevent.detailis what I was looking for, works like a charm.