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

145
Views
Elemento animado angular 2 generado por ngFor

Soy nuevo en animaciones en Angular 2, por lo que es posible que me esté perdiendo algo obvio, pero ¿cómo animo elementos generados por un bucle * ngFor? Parece que las animaciones están vinculadas a un componente y deben definirse en el decorador @Component.

¿La única solución es crear un componente interno y hacer que se cree en * ngFor y luego animarlo?

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Este es un ejemplo de una animación de aparición gradual para elementos generados en un bucle *ngFor .

mi.componente.ts

 @Component({ selector: ..., templateUrl: 'my-component.html', styleUrls: ..., animations: [ trigger('fadeIn', [ transition(':enter', [ style({ opacity: '0' }), animate('.5s ease-out', style({ opacity: '1' })), ]), ]), ], })

mi-componente.html

 <div *ngFor="let item of myArray" @fadeIn>I'm an Item</div>

NB: si desea utilizar una animación con un estado específico, debe vincular el estado de esta manera:

 [@myAnimation]="'myState'"
about 4 years ago · Santiago Trujillo Report

0

Aquí hay un ejemplo de animación de aparición y desaparición gradual basada en la respuesta de Ploppy.

 @Component({ selector: ..., templateUrl: 'my-component.html', styleUrls: ..., animations: [ trigger('inOutAnimation', [ state('in', style({ opacity: 1 })), transition(':enter', [style({ opacity: '0' }), animate('.5s ease-out', style({ opacity: '1' }))]), transition(':leave', [style({ opacity: '1' }), animate('.5s ease-out', style({ opacity: '0' }))]), ]), ], })
 <div *ngFor="let item of myArray" [@inOutAnimation]="'in'">
about 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!