After this session the project has been created; your new project should look like this. This window is called the Solution Explorer. The Solution Explorer contains the ts file, js file, CSS file, and HTML file:
Coding
super.ts
- class table {
- x: number;
- constructor(x: number, ) {
- for (var n = 1; n <= 10; n++) {
- var y = x * n;
- var span = document.createElement("span");
- span.innerText = x + "*" + n + "=" + y + "\n";
- document.body.appendChild(span);
- }
- }
- }
- var p = new table(5);
superkeyworddemo.html
- < !DOCTYPEhtml >
- <
- htmllanghtmllang = "en"
- xmlns = "http://www.w3.org/1999/xhtml" >
- <
- head >
- <
- metacharsetmetacharset = "utf-8" / >
- <
- title > Example Of Multiplication Table of 5 < /title>
- <
- linkrellinkrel = "stylesheet"
- href = "app.css"
- type = "text/css" / >
- <
- /head>
- <
- body >
- <
- h1 > Multiplication Table of 5 < /h1>
- <
- divstyledivstyle = "color:#0094ff"
- id = "content" >
- <
- scriptsrcscriptsrc = "app.js" >
- <
- /script>
- <
- /div>
- <
- /body>
- <
- /html>
app.js
- var table = (function() {
- function table(x) {
- for (var n = 1; n <= 10; n++) {
- var y = x * n;
- var span = document.createElement("span");
- span.innerText = x + "*" + n + "=" + y + "\n";
- document.body.appendChild(span);
- }
- }
- return table;
- })();
- var p = new table(5);
Output
Reference By
http://www.typescriptlang.org/