Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

174
Views
idangero.us Swiper with Angular - How to keep scope in config callback

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!

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

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();
        }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!