Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

176
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda