NG.I · Angular 22 practice question
A front-end developer is displaying a user's purchase date in a component. They want the date to automatically format according to the user's regional settings (e.g., MM/DD/YYYY for the US). Which syntax should they use in the template?
<p>Date: {{ purchaseDate | date }}</p>
Check answer and explanation
Correct answer: <p>Date: {{ purchaseDate | date }}</p>
Explanation
The appropriate syntax involves utilizing the built-in 'date' pipe, which guarantees that the output conforms to the user's locale settings, as illustrated by the example displaying US formatting.
Common trap
The syntax that employs a non-existent pipe name, and the syntax that tries to invoke a method directly on the bound property, circumventing Angular's transformation pipeline.
Source: Angular docs: Pipes — Overview
Checked against the cited text on 2026-11-25.