You can rely on routeAnimation to routeAnimation to the routeAnimation
Animations.ts
import {style, animate, transition, state, trigger} from '@angular/core'; export default [ trigger('routeAnimation', [ state('*', style({opacity: 1, height: '100%'})), transition('void => *', [ style({opacity: 0, height: '100%'}), animate(200) ]), transition('* => void', animate(0, style({opacity: 0, height: '100%'}))) ]) ];
Then in YourComponent.ts
import animations from './Animations'; @Component({ ... animations: animations }) export class YourComponent { @HostBinding('@routeAnimation') public routeAnimation:void; ... }
Optional: assumes your routing.ts file looks like
import {RouterModule} from '@angular/router'; import {ModuleWithProviders} from '@angular/core'; import {YourComponent} from './YourComponent'; export const routing:ModuleWithProviders = RouterModule.forChild([ {path: "aPath", component: YourComponent} ]);
Flavien volken
source share