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