0

In angular elements, as per the docs and this SO question says emits a custom event whenever we emit a value using @output event emitter. But it's actually cumbersome to handle in the real usage side. Is there any other way to get the real value emitted other than calling $event.detail?

FYI:

if The published value = 'abc,

Then the event is like

CustomEvent {isTrusted: false, detail: "abc", type: "ngModelChange", ... }
Kavinda Jayakody
  • 705
  • 1
  • 13
  • 25
  • u can use service without emitters if u want – PushpikaWan Apr 05 '20 at 19:42
  • You find it cumbersome to get the value with `$event.detail`? What would you consider not cumbersome? – ConnorsFan Apr 05 '20 at 19:45
  • Sorry, I don't understand your question, if you use in your component, this.myOutput.emit("abc"), $event get the value "abc" – Eliseo Apr 06 '20 at 18:07
  • @ConnorsFan haha problem is with my question. Actually it's not cumbersome to use like $event.detail when in the ts file or anywhere. But here i am using this as the [(ngMode)]="bindingVariable" style. You got the point why i'm telling this cumbersome now? :D. Coz when we have a bind like that, it's almost impossible to get the actual value we passed (What we get is the whole custom event) – Kavinda Jayakody Apr 07 '20 at 16:00
  • @Eliseo no actually. When i'm using the outputed value. The value coming up is something like the event that i have posted (CustomEvent {isTrusted: false, detail: "abc", type: "ngModelChange", ... }) – Kavinda Jayakody Apr 07 '20 at 16:01
  • @ConnorsFan P.S. :- I'm manually implementing the ngModel and ngModelChange thing because when in custom elements (angular elements) it don't work – Kavinda Jayakody Apr 07 '20 at 16:02

0 Answers0