Trying to fade in the Angular Router Outlet.
This is the CSS Code (app-component.css).
router-outlet * {
display: block;
animation: fade 1s;
}
@keyframes fade {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
But, sibling for router-outlet
will be always a different component injected by RouterModule
.
In order to solve the issue, there are two solutions.
- Move
router-outlet *
animation css tostyles.css
file. - Add
encapsulation: ViewEncapsulation.None
inapp.component.ts
file as shown below.