Given the component property name = 'Angular', what will be displayed by this template?
<div>{{ name | lowercase | slice:0:4 | uppercase }}</div>Remember that pipes are applied from left to right, and each pipe transforms the output of the previous one.
The lowercase pipe converts 'Angular' to 'angular'. Then slice:0:4 extracts 'angu'. Finally, uppercase converts it to 'ANGU'.
Assuming today = new Date('2024-06-15'), which template expression correctly formats the date as 'Jun 15, 2024' and then converts it to uppercase?
Pipes are chained left to right. The uppercase pipe works on strings, so it must come after the date pipe.
Option B correctly formats the date first, then uppercases the string. Option B tries to uppercase a Date object, which fails. Options A and D use invalid pipe syntax.
Given value = null, what happens with this template?
<div>{{ value | uppercase | slice:0:3 }}</div>Angular built-in pipes like uppercase and slice handle null safely without throwing errors.
No error occurs. The uppercase pipe returns null for null input, and the slice pipe returns an empty string.
Component code:
name = 'Angular';
changeName() { this.name = 'Framework'; }
Template:
<div>{{ name | slice:0:4 | uppercase }}</div>
<button (click)="changeName()">Change</button>What is shown before and after clicking the button?
Remember slice:0:4 takes first 4 characters, and uppercase converts to uppercase.
Initially, 'Angular' sliced to 'Angu' then uppercased to 'ANGU'. After changing to 'Framework', sliced to 'Fram' then uppercased to 'FRAM'.
Consider these two expressions:
1. {{ text | lowercase | slice:0:3 }}
2. {{ text | slice:0:3 | lowercase }}Which statement is true?
Think about how the output of one pipe becomes the input of the next.
Pipe chaining applies pipes left to right. Changing order changes intermediate values, so output can differ.