1

I have a javascript function named "gimmick" which is inside index.html. And I have a typescript function. My criteria is to call the javascript function from inside of the typescript function. Some one please suggest some idea so that I can access the javascript function from typescript.

1 Answer 1

3

This is how I do it:

  1. in your index.html file :

    <button id="callMyJSFunction" onclick="myJSFunction()" style="display:none;"></button> <script> function myJSFunction(){ alert('IN'); } </script>
    
  2. in your ts file:

    myTSFunction(){ var btn = document.getElementById('callMyJSFunction'); btn.onclick.apply(btn); }
    
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.