Bird
0
0

An Angular impure pipe is not recalculating output as expected. Which fix is most appropriate?

medium📝 Debug Q7 of 15
Angular - Pipes
An Angular impure pipe is not recalculating output as expected. Which fix is most appropriate?
AChange pure property to true in @Pipe decorator.
BRemove the pipe from the declarations array.
CUse the pipe only with primitive inputs.
DEnsure the pipe's transform method returns a new object or value.
Step-by-Step Solution
Solution:
  1. Step 1: Identify cause of no recalculation

    Impure pipes run every cycle but output depends on transform method returning new values.
  2. Step 2: Choose fix

    Returning new objects or values ensures Angular detects changes and updates output.
  3. Final Answer:

    Ensure the pipe's transform method returns a new object or value. -> Option D
  4. Quick Check:

    Impure pipes need new output to trigger updates [OK]
Quick Trick: Return new values in transform for impure pipes [OK]
Common Mistakes:
  • Switching to pure pipe incorrectly
  • Removing pipe from declarations
  • Limiting pipe usage to primitives unnecessarily

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes