I have used an angular animation (fade-in, fade-out) on a modal component in my project.
The modal is set to open when clicking on a button somewhere else on a different component (using a modal service).
The animation code in the component which hosts the modal component:
animations: [
trigger('modalVisibilityChanged', [
state(
'shown',
style({
opacity: 1,
visibility: 'visible'
})
),
state(
'hidden',
style({
opacity: 0,
visibility: 'hidden'
})
),
transition('shown => hidden', animate('500ms ease-in')),
transition('hidden => shown', animate('500ms ease-out'))
])]
And the html:
<app-modal [@modalVisibilityChanged]="visibility"></app-modal>
This animation worked perfectly until I've set the modal content to be loaded and inserted into the modal component dynamically (using ng-template in the modal's component html).
After that the animation no longer works (the relevant css properties don't change when clicking on the button) and the modal components div gets the class "ng-animate-queued" when inspected using Google Chrome.
This is how it looks:
Can anyone help me solve the problem, or share what is the cause?
Thanks!