Angular2 call function in html from Component

From my angular2 component, I would like to run a function in my html page.

Example:

<script> 
   function doAlert(){
      alert("in doAlert");
   }
</script>

This is needed as i am integrating my app into a html page for a third party. And i need to update them on events done in the app.

In the below, i manage to do this using window.doAlert(); is there an alternative to using window.

http://plnkr.co/edit/vZtjbATax5yvmwJVWRrJ?p=preview

2
Leave a Reply

avatar
2 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
Jason Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Jason
Guest

i assumed from your question you are stuck on event binding in angualr so try this-

<button (click)='demoFun()'> Button </button>

demoFun(){
//your code..//
}

here is working example http://plnkr.co/edit/4UPlh9Pn42yM3VPqYvoL?p=preview
for more refer see here

Jason
Guest

Not sure if this was ever solved for by you.

But I use {{ functionName() }}
and just return back the information i need.