ts-browser
ts-browser copied to clipboard
Accessing functions and variables from HTML
It seems all typescript code are wrapped in a function and called and this leads to function declarations not to be globally available. How can I declare functions in typescript file globally? For example :
index.ts
function handleClick(){ }
index.html<div onclick="handleClick()"></div>
Here handleClick is not found, because it is wrapped in an outer function before calling
I figured one way of doing this would be :
Object.assign(window, { yourFunctionOne, yourFunctionTwo })