This should be very basic but I am unable to get through it.
I have a class like:
class MyObject {
value: number;
unit: string;
constructor(value: number, unit: string){
this.value = value;
this.unit = unit;
}
}
Then in HTML,
<input id="myValue" type="number"></input>
<input id="myUnit" type="text"></input>
I want to create an Object of "MyObject" class using myValue and myUnit. How do I do that ?
Something like:
var value = document.getElementById("myValue");
var unit = document.getElementById("myUnit");
myObject: MyObject = new MyObject(value, unit);
Unable to do it the above way. What's the way to go about with this ?