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

215
Vistas
How to import an uploaded JS file?

I have an Angular application using a Plugin- Architecture from this article In this article the build bundle.js file is exported and imported in the application from assets folder using .import(filepath). What I am trying to do is instead of importing the saved file, I want to upload a file and import that file.

I know how to read and evaluate a JS file by uploading using the below code. But, I am not sure how to make it work with an Angular build file. Any idea?

function handleFileInput(files) {
  var fileContent = document.getElementById('contnt');
  var fileToUpload = files.item(0);
  var textType = /text.*/;

  if (fileToUpload.type.match(textType)) {
    var reader = new FileReader();

    reader.onload = function(e) {
      const x = eval(reader.result)
      fileContent.innerText = x;
    }

    reader.readAsText(fileToUpload);
  } else {
    fileContent.innerText = "File not supported!"
  }
}
<input id="fileInput" type="file" name="file" (change)="handleFileInput($event.target.files)" />
<pre id="fileContent"></pre>

<div id="contnt"></div>

about 4 years ago · Juan Pablo Isaza
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