I am trying to use typescript in my application. for the same I am doing an POC and in POC i want to call a function Defined in TypeScript class on button click.
Is it possible to call the function? If yes then how?
So far I have seen examples where the functions are called on Page load only. I need to call a function on certain event.
Thanks.
I need to call a function on certain event.
If the function is global e.g. TypeScript:
function foo(){
alert('foo');
}
Just use onclick
e.g. html:
<button onclick="foo()">click me!</button>
Remember TypeScript is (almost) JavaScript.
However I recommend using a framework like angular with TypeScript. For maintainability. As an example take a look at the browser quickstart.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With