Angular · Junior · Question 18 of 75
How do you conditionally render a block in modern Angular templates?
@if (user) {
<p>Hello, {{ user.name }}</p>
} @else {
<p>Please sign in</p>
}- ✓Correct answer: With the built-in
@if/@elseblock shown above - 2Only with
*ngIf, the block syntax does not exist - 3With
v-if="user"
Explanation
Built-in control flow (@if, @for, @switch) has been stable since Angular 17. It needs no imports and is faster than the older *ngIf/*ngFor structural directives.