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

224
Vistas
import number variable from .ts to html <script>

I want to export the variable 'myVariable' from getVariable.ts

export class getVariable {

      myVariable: number = 0;           

}

And use it in my html to show a button or not: I tried to import the .ts but there is no value in the variable 'myVariable'. How can I import the variable?

 <button type="button" id="btn1" class ="btn1"> btn1 </button>
 <button type="button" id="btn2" class="btn2"> btn2 </button>
 <script>          
                                import {getVariable } from "../getVariable ";
                                var statement = getVariable.myVariable;
                                if (statement != 0) {
                                    document.write('<button type="button" id="btn3" class="btn3"> btn3 </button>');
                                }
                                  
 </script>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Prepend your variable with static.

export class getVariable {
 static myVariable: number = 0;           
}
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