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

416
Views
¿Cómo puedo acceder al índice fuera de *ngFor?

Quiero usar la variable i fuera de mi ngFor. ¿Qué opciones hay para solucionar este problema?

Aquí hay un pequeño ejemplo de aplicación:

 <ng-container *ngFor="let selection of selectionNumber; index as i;"> <app-MyDropdown tabindex="{{i}}" ></app-MyDropdown ></ng-container> <div> <button type="button" tabindex="{{i+1}}" > Button 1 </button> <button type="button" color="primary" tabindex="i+2" > Button 2 </button> </div>

Quiero usar la variable i fuera del ciclo for para establecer el índice de tabulación. Para esto i debería tener el último valor de la iteración del ciclo.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

No es posible usar ningún valor de * ngFor fuera de cualquier elemento en el que esté ejecutando su bucle ngFor (en su caso, es ng-container). Lo que significa que debe colocar sus botones dentro de su ngContainer que creará un botón. Pero no estoy seguro si eso es lo que quieres lograr.

about 4 years ago · Juan Pablo Isaza Report

0

No puede acceder a ningún dato de *ngFor desde fuera del ciclo

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!