Prepare for Angular Interviews with real-life questions. Utilize quizzes and examples to deepen understanding and enhance your skills. Gear up to ace your interview!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


Which method must a custom pipe implement in Angular?

  1. initialize

  2. execute

  3. transform

  4. process

The correct answer is: transform

In Angular, a custom pipe must implement the `transform` method to function correctly. This method is a critical part of the `PipeTransform` interface that all custom pipes must adhere to. The `transform` method takes an input value and transforms it according to the specified logic that the developer defines. When a pipe is used in a template, Angular invokes the `transform` method with the provided input value and any additional arguments that may be passed. This allows the pipe to process the input and return the transformed result, which can then be displayed in the user interface. This method is what enables developers to create reusable data transformation logic that can be applied directly within the Angular template syntax. For example, if a custom pipe is designed to format dates, the `transform` method would take a date input and return it in the desired string format. The flexibility of the `transform` method allows for various transformations to be created, making Angular pipes a powerful feature for managing the presentation of data. The other choices, while appearing plausible, do not correspond to any methods required for custom pipes in Angular. Therefore, the `transform` method is an essential component that every custom pipe must implement to maintain compatibility with Angular's templating system.