Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

221
Views
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 answers
Answer question

0

Prepend your variable with static.

export class getVariable {
 static myVariable: number = 0;           
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!