Which of the following is the correct syntax to chain the 'date' and 'uppercase' pipes in Angular?
easy📝 Syntax Q3 of 15
Angular - Pipes
Which of the following is the correct syntax to chain the 'date' and 'uppercase' pipes in Angular?
A{{ today | uppercase | date:'shortDate' }}
B{{ today | date:'shortDate' | uppercase }}
C{{ today | date('shortDate') | uppercase }}
D{{ today | date:'shortDate' uppercase }}
Step-by-Step Solution
Solution:
Step 1: Understand pipe chaining order and syntax
Pipes are chained with | and parameters use colons, not parentheses.
Step 2: Check each option's syntax and order
{{ today | date:'shortDate' | uppercase }} correctly chains date pipe with parameter then uppercase pipe. {{ today | uppercase | date:'shortDate' }} reverses the order, which changes the output since date expects a Date object. The remaining options have syntax errors (parentheses for parameters and missing pipe separator).
Final Answer:
{{ today | date:'shortDate' | uppercase }} -> Option B