title: Pass angular component function to javascript function - boxfactura
body: <p>I am implementing <a href="https://www.boxfactura.com/pulltorefresh.js/" rel="nofollow noreferrer">this</a> feature in my angular code to pull to refresh data and its pretty straightforward.</p>
  <pre><code>const ptr = PullToRefresh.init({
    mainElement: 'div.custom-div'
     onRefresh() {
       this.getData();
     }
  });
  </code></pre>
  <p>and i have a function in my component called getData()</p>
  <pre><code>export class HomeComponent implements OnInit {
  
  constructor() {}
  
  ngOnInit(): void {
  
  const ptr = PullToRefresh.init({
    mainElement: 'div.custom-div'
     onRefresh() {
       this.getData();
     }
  });
  
  }
  
  getData() {
    // get data function
  }
  }
  </code></pre>
  <p>but I'm having a hard time calling that from the javascript function. It throws the error</p>
  <pre><code>getData is not a function
  </code></pre>
  <p>and I know it does this because it reads this as the js function instead of the component it is embedded in. How can i go about this correctly?</p>