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

173
Views
Creé una `const` dentro de `this.api.getApi().subscribe(({tool,beuty})`, ¿cómo puedo ejecutarla dentro de mi declaración `if`?

Creé una const dentro this.api.getApi().subscribe(({tool,beuty}) , ¿cómo puedo ejecutarla dentro de mi declaración if como esta:

 if (evt.index === 0) {aa}

Crearé más líneas como esta y quiero ejecutarlas con diferentes sentencias if :

 this.beu=beuty.slice(0,this.i+=15);

¿Hay una mejor solución para hacer eso?

Código:

 onScrollDown(evt:any ) { setTimeout(()=>{ this.api.getApi().subscribe(({tool,beuty}) => { const aa=this.beu=beuty.slice(0,this.i+=15); }) if (evt.index === 0) {aa} },1000); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No puede acceder a una variable declarada usando const fuera de su alcance de bloque. Pruebe lo siguiente y obtendrá un ReferenceError :

 function foo() { const bar = "bar"; } console.log(bar);

Por lo tanto, no puede usar aa fuera de la devolución de llamada pasada a this.api.getApi().subscribe() .

Si desea poder usar aa fuera de la devolución de llamada, puede definir aa usando let . En codigo:

 onScrollDown(evt:any) { setTimeout(() => { // Add this: let aa; this.api.getApi().subscribe(({tool,beuty}) => { // Change this: aa=this.beu=beuty.slice(0,this.i+=15); }) if (evt.index === 0) {aa} }, 1000); }

Espero que esto ayude. Realmente no puedo decir si funciona porque no tengo el guión completo.

about 4 years ago · Juan Pablo Isaza 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!