I've been trying to understand working with callbacks to be able to keep the scope on a callback that I am trying to run but am still missing something.
Swiper (for Angular at least) uses "config" to set pagination, slidesPerView, etc. including what to do when the user reaches the last slide (onReachEnd) but I can't maintain my scope inside of that callback which looks like this:
config: any = {
pagination: '.swiper-pagination',
...
...
onReachEnd: function(swiper){
console.log(this.userName);
}
};
and returns "undefined" for this.userName.
I've tried to use bind inside the onReachEnd callback but "this" is already undefined which makes me think I have to plug it in at a higher level but am not sure how that works or if that is either the correct way to go about this.
Thanks for any input or advice!
So I found another problem on a forum that happened to list an example of that I needed so in case anyone has a similar problem here is the answer, it is a lot simpler than I imagined. If this is not a solid way to do this please let me know.
onReachEnd: () => {
this.yourFunctionHere();
}