Getting trouble in accessing set_id
method inside MyClass
class in HTML elemen button using TypeScript.
Here's my code:
HTML
<button onclick="myClassObject.set_id(1)">Set ID</button>
TypeScript
class MyClass {
set_id(id: number) {
console.log(id);
}
}
let myClassObject = new MyClass();
Error
Uncaught ReferenceError: myClassObject is not defined at HTMLButtonElement.onclick ((index):15)
By the way: I am new in TypeScript. hehe.
Can someone help me?
Update: I'm using webpack to compile my TS