import { Component, Input } from '@angular/core'; import { trigger, state, style, animate, transition } from '@angular/animations'; import { Hero } from './hero.service'; @Component({ selector: 'app-hero-list-enter-leave', // #docregion template template: ` `, // #enddocregion template styleUrls: ['./hero-list.component.css'], /* The element here always has the state "in" when it * is present. We animate two transitions: From void * to in and from in to void, to achieve an animated * enter and leave transition. The element enters from * the left and leaves to the right using translateX. */ // #docregion animationdef animations: [ trigger('flyInOut', [ state('in', style({transform: 'translateX(0)'})), transition('void => *', [ style({transform: 'translateX(-100%)'}), animate(100) ]), transition('* => void', [ animate(100, style({transform: 'translateX(100%)'})) ]) ]) ] // #enddocregion animationdef }) export class HeroListEnterLeaveComponent { @Input() heroes: Hero[]; }