index.ts
1 import EmbarkJS from 'Embark/EmbarkJS'; 2 //import your contracts 3 //e.g if you have a contract named SimpleStorage: 4 //import SimpleStorage from 'Embark/contracts/SimpleStorage'; 5 6 class Greeter { 7 greeting: string; 8 constructor(message: string) { 9 this.greeting = message; 10 } 11 greet() { 12 return "Hello, " + this.greeting; 13 } 14 } 15 16 document.addEventListener("DOMContentLoaded", function() { 17 EmbarkJS.onReady(function() { 18 // Interact with contracts, storage, etc.. 19 }); 20 21 let greeter = new Greeter("world"); 22 23 let button = document.createElement('button'); 24 button.textContent = "Say Hello"; 25 button.onclick = function() { 26 alert(greeter.greet()); 27 } 28 29 document.body.appendChild(button); 30 }); 31