Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

251
Vistas
Angular 4 - new MouseEvent causes IE11 error

I have problem with mouseEvent in angular 4 on IE11. I am using angular 4, angular-cli.

When I activate this line of code:

let newEvent = new MouseEvent('mouseleave', {bubbles: true});

IE is throwing such exception in console:

TypeError: Object does not support this operation.
   at MenuItemComponent.prototype.onClick (./main.bundle.js:821:13)
   at Anonymous function (Function code:37:9)
   at handleEvent (./vendor.bundle.js:12039:87)
   at callWithDebugContext (./vendor.bundle.js:13247:9)
   at debugHandleEvent (./vendor.bundle.js:12835:5)
   at dispatchEvent (./vendor.bundle.js:9014:5)
   at Anonymous function (./vendor.bundle.js:9604:31)
   at Anonymous function (./vendor.bundle.js:19253:9)
   at ZoneDelegate.prototype.invokeTask (./polyfills.bundle.js:10732:13)
   at onInvokeTask (./vendor.bundle.js:4357:21)
   at ZoneDelegate.prototype.invokeTask (./polyfills.bundle.js:10732:13)
   at Zone.prototype.runTask (./polyfills.bundle.js:10501:21)
   at invoke (./polyfills.bundle.js:10796:21)

I uncommented everything in my polyfils.ts and rebuilded project, I have tried IE and ES6 shims...

I can not find anything similar in Google, and I think this is some silly issue - cloud somebody please point me to solution?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

You can trick for IE by:

import { Component, OnInit, ElementRef, ViewChild } from '@angular/core';

...

@ViewChild('fileInput') public fileInput: ElementRef;

...

// Trigger button click event
let event;
if (document.createEvent){
  // Only for IE and Firefox
  event = document.createEvent('MouseEvent');
  event.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
} else {
  // For Chrome
  event = new MouseEvent('click', {bubbles: false});
}
this.button.nativeElement.dispatchEvent(event);
over 4 years ago · Santiago Trujillo Denunciar

0

Try in html file:

<div #sample>You need to click me</div>

in component.js file:

@ViewChild('sample') sampleEle: ElementRef;

and the use the click event as in the js as:

this.sampleEle.nativeElement.click();
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda