I'm still new to Angular 2 and was wondering if there is a way to let a component 'fly in' and let another component 'fly out' when switching routes. Let's say I have 2 components: Test1Component and Test2Component and 2 routes pointing to each of them. What would be the best way to do it?
Asked
Active
Viewed 5,151 times
1 Answers
3
https://github.com/angular/angular/issues/9845#issuecomment-235799008
RC5 will hopefully be out this week, if not then next week.
For now (with RC5) you will need to do this for every component that is routed to and you want to add animations to:
@Component({ host: { '[@routeAnimation]': 'true' }, animations: [ trigger('routeAnimation', [ transition('* => void', animate(...)), transition('void => *', animate(...)) ]) ] }) class Cmp { }
Once we get
query()
and$variables
into animations then you can use<router-outlet>
with the URL API that I wrote above.

Günter Zöchbauer
- 623,577
- 216
- 2,003
- 1,567
-
Thank you, but can you tell me how to bind it properly? It's giving me this error: "Can't bind to '@routeAnimation' since it isn't a known native property". – Patryk Siwula Jul 28 '16 at 10:48
-
I haven't tried animations myself yet. Did you check https://angular.io/docs/ts/latest/guide/animations.html? – Günter Zöchbauer Jul 28 '16 at 11:03