Bird
0
0

Which of the following is the correct way to declare an impure pipe in Angular?

easy📝 Syntax Q12 of 15
Angular - Pipes
Which of the following is the correct way to declare an impure pipe in Angular?
A@Pipe({ name: 'examplePipe', pure: false })
B@Pipe({ name: 'examplePipe', impure: true })
C@Pipe({ name: 'examplePipe' })
D@Pipe({ name: 'examplePipe', pure: true })
Step-by-Step Solution
Solution:
  1. Step 1: Recall pipe metadata syntax

    Angular pipes use the @Pipe decorator with a 'pure' property to indicate purity.
  2. Step 2: Identify impure pipe declaration

    Setting 'pure: false' marks the pipe as impure, causing it to run every change detection cycle.
  3. Final Answer:

    @Pipe({ name: 'examplePipe', pure: false }) -> Option A
  4. Quick Check:

    Impure pipe uses pure: false [OK]
Quick Trick: Impure pipes set pure to false in @Pipe decorator [OK]
Common Mistakes:
  • Using pure: true for impure pipes
  • Omitting pure property defaults to pure
  • Using non-existent 'impure' property

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes