Necesito usar document.element.dispatchEvent(new CustomEvent('myCustomEvent', 'The string that I try to send when fire event from code')) pero se activó un error de sintaxis con este código porque el segundo argumento de CustomEvent debe ser un objeto, no puede ser una cadena simple, este es el primer problema, debo enviar el evento sin datos solo con una cadena simple y recibirlo sin ningún otro dato en la función de devolución de llamada angular, ¿hay algo al respecto?
Utilice @Output de Angular si solo desea pasar datos a los componentes principales.
@Output() public myCustomEvent: EventEmitter<string> = new EventEmitter(); .... this.myCustomEvent.emit('The string that I try to send when fire event from code')Referencia: https://angular.io/guide/inputs-outputs