Complete the code to import the Angular animations module.
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; @NgModule({ imports: [[1]] }) export class AppModule {}
The BrowserAnimationsModule enables Angular animations in your app.
Complete the code to define a simple fade-in animation trigger.
import { trigger, transition, style, animate } from '@angular/animations'; @Component({ animations: [ trigger('fadeIn', [ transition(':enter', [ style({ opacity: 0 }), [1]('500ms ease-in', style({ opacity: 1 })) ]) ]) ] }) export class MyComponent {}
style instead of animate for timing.trigger or transition here.The animate function defines the animation duration and style changes.
Fix the error in the animation trigger name usage in the template.
<div [@[1]]="''">Content</div>
The animation trigger name must match exactly the name defined in the component, which is fadeIn.
Fill both blanks to create a slide animation that moves an element from left to right.
animations: [ trigger('slideRight', [ transition(':enter', [ style({ transform: '[1]' }), animate('300ms ease-out', style({ transform: '[2]' })) ]) ]) ]
The element starts off-screen to the left with translateX(-100%) and slides to its original position translateX(0).
Fill all three blanks to create a toggle animation that changes height and opacity.
animations: [ trigger('toggleHeight', [ transition('void => *', [ style({ height: '[1]', opacity: [2] }), animate('400ms ease-in-out', style({ height: '[3]', opacity: 1 })) ]) ]) ]
The element starts with zero height and invisible opacity, then animates to its natural height * and full opacity.