This is a simple demonstration of how to use the animation framework
The animation (adjust as needed):
import {
trigger,
style,
transition,
animate,
} from '@angular/animations';
export const FadeAnimation = trigger(
'fadeAnimation', [
transition(':enter', [
style({
opacity: 0
}
),
animate(
200,
style({
opacity: 1
})
)
]),
transition(':leave', [
animate(
200,
style({
opacity: 0
})
)
])
]
);
In the component (include the animation):
@Component({
selector: 'your-selector',
templateUrl: './your-component-name.component.html',
styleUrls: ['./your-component-name.component.css'],
animations: [
FadeAnimation,
]
})
In the html (if condition is true: set opacity to 1, else set it to 0):
<ul*ngFor ="let product of products let i = index" >
<li [ngClass]="{'highlightClass': i%2==0}" [@fadeAnimation]="true">
<span> Text will be displayed here</span>
<span> Additional text goes here </span>
</li>
</ul>
I trust this information proves useful.