Bird
0
0

Given this custom pipe code, what will be the output of {{ 'hello' | exclaim }} if the pipe is defined as:

medium📝 component behavior Q13 of 15
Angular - Pipes
Given this custom pipe code, what will be the output of {{ 'hello' | exclaim }} if the pipe is defined as:
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'exclaim' })
export class ExclaimPipe implements PipeTransform {
  transform(value: string): string {
    return value + '!';
  }
}
AError: Pipe not found
Bhello
Chello!
D!hello
Step-by-Step Solution
Solution:
  1. Step 1: Understand the transform method behavior

    The transform method appends an exclamation mark to the input string.
  2. Step 2: Apply the pipe to the input 'hello'

    Input 'hello' becomes 'hello!' after transformation.
  3. Final Answer:

    hello! -> Option C
  4. Quick Check:

    Input + '!' = hello! [OK]
Quick Trick: transform method output is what pipe shows [OK]
Common Mistakes:
  • Ignoring the transform method logic
  • Assuming pipe adds prefix instead of suffix
  • Not registering the pipe in module (causing errors)

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes