Home > OS >  Fading in the Angular Router Outlet?
Fading in the Angular Router Outlet?

Time:01-04

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;
  }
}

enter image description here

But, sibling for router-outlet will be always a different component injected by RouterModule.

In order to solve the issue, there are two solutions.

  1. Move router-outlet * animation css to styles.css file.
  2. Add encapsulation: ViewEncapsulation.None in app.component.ts file as shown below.

enter image description here

  • Related