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

160
Vistas
Pass content of ts variable in js file

I was wondering if it's possible to use the content of a ts variable and use it in js file ? I'm feeling trapped now I realize that I don't know how can I achieve it.

Please send me any suggestion easy to implement if possible.

My ts file with the printedOption that I want to use in my js file. The content of this variable is the value of my select input.

 validateLuggages() {
      this.printedOption = this.selectedOption;
      this.http.get(`/routes/luggages`)
        .subscribe((data) => {
          this.parsedForLuggages = data;
     })
      return this.printedOption;
}

Now, How can I create the instance and use this variable in my JS file ?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

To use any typescript variable inside javascript code you may firstly export the variable in typescript file which you want to use in the js file.

Then, you can simply use the import statement and import the variable from the correct path.

You can check the example below and refer the link for better clarity. LINK

// Add to tsconfig.json:

{ "compilerOptions": { ... "allowJs": true ... } }

import MyModule from './../pages/MyModule';

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