title: How to call ts function from js code and pass variable value
body: <p>I have this situation where on clicking the html element i am fetching value of attribute in <code>home.ts</code> using jquery. When the button is clicked,I want to call a function and pass this fetched attribute's value in a variable in the called function. </p>
  
  <p>Below is my code:</p>
  
  <p><code>**home.html**</code></p>
  
  <pre><code>&lt;div id="mainDiv"&gt;
    &lt;span action="10004"&gt;Quick Task&lt;/span&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><code>**home.ts**</code></p>
  
  <pre><code>//declare var $: any;
  import { Component } from '@angular/core';
  import { NavController } from 'ionic-angular';
  import $ from "jquery"; //intentional use of jQuery
  
  @Component({
    selector: 'page-home',
    templateUrl: 'home.html'
  })
  export class HomePage {
  
    constructor(public navCtrl: NavController) {
  
    }
  
    actionid;
  
    ngOnInit(){
      var mainDiv = document.getElementById("mainDiv");
      mainDiv.addEventListener("click", function (event) {
        console.log("Inside Event Listener");
        event.preventDefault();
          var link_id = $(event.target).attr("action");
          console.log("Actionid is:: " + link_id);
        //  this.actionid = link_id;
        //  var x = this.callpagedata();
    });
    }
  
    callpagedata(){
  console.log("callpagedata function fired,actionid is::", this.actionid)
    }
  
  }
  </code></pre>
  
  <h2>Edit</h2>
  
  <p>Something like this needs to be used:</p>
  
  <p><code>this.actionid = HTMLElement.addEventListener&lt;"click"&gt;.......</code></p>