У меня была похожая проблема. Я решил это, поместив функцию непосредственно в свой компонент, вместо этого используя экспортированную функцию.
export function slideToLeft () {
return [
query(':enter, :leave', [
style({
position: 'absolute',
top: 0,
left: 0,
width: '100%'
})
], { optional: true }),
query(':enter', [
style({ left: '-100%'})
]),
group([
query(':leave', [
animate('600ms ease', style({ left: '100%'}))
], { optional: true }),
query(':enter', [
animate('600ms ease', style({ left: '0%'}))
])
]),
];
}
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
animations: [
trigger('routeAnimations', [
transition('FirstPage => SecondPage', slideToRight())
])
]
})
export class AppComponent implements ...
const routes: Routes = [
{
path: 'home/firstPage',
component: FirstPageComponent,
canActivate: [AuthGuard],
data: {
animation: 'FirstPage'
},
},
{
path: 'home/secondPage',
component: SecondPageComponent,
canActivate: [AuthGuard],
data: {
animation: 'SecondPage'
},
}
]
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class RoutingModule { }