Bird
0
0

You wrote this animation trigger but it does not run:

medium📝 Debug Q14 of 15
Angular - Animations
You wrote this animation trigger but it does not run:
trigger('slideIn', [
  transition('void => *', [style({ transform: 'translateX(-100%)' }), animate('300ms ease-in')])
])

What is the likely reason it does not animate when the element appears?
AThe trigger name 'slideIn' is not added to the component's animations array.
BThe transition syntax 'void => *' is invalid and causes errors.
CThe style property 'transform' cannot be animated in Angular.
DThe animate duration '300ms' is too short to see any effect.
Step-by-Step Solution
Solution:
  1. Step 1: Check if the animation trigger is registered

    Animations must be included in the component's animations array to run.
  2. Step 2: Verify transition syntax and properties

    'void => *' is valid syntax, and 'transform' can be animated; duration is reasonable.
  3. Final Answer:

    The trigger name 'slideIn' is not added to the component's animations array. -> Option A
  4. Quick Check:

    Animations must be registered in component [OK]
Quick Trick: Always add triggers to animations array in component decorator [OK]
Common Mistakes:
  • Forgetting to add animations array in @Component
  • Misunderstanding transition syntax
  • Thinking short duration disables animation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes