只要稍加改动,对我就行了。
动画:
animations: [
trigger('fadeInOut', [
transition(':increment', [
query(':enter', [
style({ opacity: 0 }),
animate('500ms', style({ opacity: 1 })),
])
]),
transition(':decrement', [
query(':leave', [
animate('500ms', style({ opacity: 0 })),
])
]),
])
]
组成部分:
export class AppComponent {
list = [
"Element 1",
"Element 2",
"Element 3"
];
itemsTotal = 3;
add(): void {
this.list.splice(0, 0, "Element 4")
this.itemsTotal++;
}
}
html:
<div class="wrp" [@fadeInOut]="itemsTotal">
<div class="si" *ngFor="let item of list">{{item}}</div>
</div>