We have been working on the
MathDemo class. We have implemented and tested its features using unit tests and assertions. Now we are going to create a little web widget that will internally use the
MathDemo class to perform a mathematical operation. We can think of this new class as a graphical user interface for the
MathDemo class. We need the following HTML:
<div id="widget"> <input type="text" id="base" /> <input type="text" id="exponent" /> <input type="text" id="result" /> <button id="submit" type="submit">Submit</button> </div>
In the companion code, the HTML code contains more attributes, such as CSS classes; but they been have removed here for clarity.
Let's create a file named
calculator_widget.ts under ...