I am creating a component based on a condition:
<div *ngIf="showContainer" class="container">
And now I want to add some animation to it, meaning I want to blend in the container instead of having it just pop up. I was thinking about the following:
<div *ngIf="showContainer" class="container" [ngClass]="{'show': showContainer, 'hide': !showContainer}">
And then in my SCSS file, I am adding the following:
.container {
transition: opacity 3s linear;
&.show {
opacity: 1;
}
&.hide {
opacity: 0;
}
}
Now, this animation does not work at all. I am toggling the showContainer
variable on clicking an icon and I have verified that the variable is actually being toggled! I have a feeling this might be connected to the *ngIf
directive. Can somebody help me out?