mujtaba01 / ngx-owl-carousel

An angular2 (4) wrapper for jquery owl-carousel library with dynamic carousel item change detection
MIT License
70 stars 25 forks source link

callback function not working properly #23

Closed shabbir-dhangot closed 6 years ago

shabbir-dhangot commented 6 years ago
carouselOptions: any = {
  nav : true, 
  dots: false, 
  loop:false,
  onChange : this.onChange, 
  items:1, 
  navText:['<i class="fa fa-chevron-circle-left" aria-hidden="true"></i>','<i class="fa fa-chevron-circle-right" aria-hidden="true"></i>']
  }

I have written callback function for onChange event. Its printing console correctly. But when I want to access other function or variable it always showing as undefined.

For example I want to access owlSlider1 then it showing undefined in that method only. on other methods that variable is working

mujtaba01 commented 6 years ago

Change this.onChange to this.onChange.bind(this)

shabbir-dhangot commented 6 years ago

This basic event binding information need to be in readme file.