Created
October 2, 2012 10:12
-
-
Save anonymous/3818003 to your computer and use it in GitHub Desktop.
TypeScript implements keyword
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface IGreeter { | |
greeting: string; | |
greet() : string; | |
} | |
class Greeter implements IGreeter{ | |
greeting: string; | |
constructor (message: string) { | |
this.greeting = message; | |
} | |
greet() { | |
return "Hello, " + this.greeting; | |
} | |
} | |
var greeter = new Greeter("world"); | |
var button = document.createElement('button') | |
button.innerText = "Say Hello" | |
button.onclick = function() { | |
alert(greeter.greet()) | |
} | |
document.body.appendChild(button) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment