Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Accessing functions and variables from HTML #11

Open
kanatkubash opened this issue Nov 17, 2021 · 1 comment
Open

Accessing functions and variables from HTML #11

kanatkubash opened this issue Nov 17, 2021 · 1 comment

Comments

@kanatkubash
Copy link

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

@kanatkubash
Copy link
Author

I figured one way of doing this would be :

Object.assign(window, { yourFunctionOne, yourFunctionTwo })

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant