You should read up on Routable Animations. Check out this blog post by Matias Niemelä (guy responsible for @angular/animations).
new-wave-of-animation-features
TL;DR:
<!-- app.html -->
<div [@routeAnimation]="prepRouteState(routerOutlet)">
<!-- make sure to keep the ="outlet" part -->
<router-outlet #routerOutlet="outlet"></router-outlet>
<div>
// app.ts
@Component({
animations: [
trigger('routeAnimation', [
// no need to animate anything on load
transition(':enter', []),
// but anytime a route changes let's animate!
transition('homePage => supportPage', [
// ... some awesome animation here
]),
// and when we go back home
transition('supportPage => homePage', [
// ... some awesome animation here
])
])
]
})
class AppComponent {
prepRouteState(outlet: any) {
return outlet.activatedRouteData['animation'] || 'firstPage';
}
}
<!-- app-routing.module.ts -->
const ROUTES = [
{ path: '',
component: HomePageComponent,
data: {
animation: 'homePage'
}
},
{ path: 'support',
component: SupportPageComponent,
data: {
animation: 'supportPage'
}
}
]