Angular - Directives
You need to show different greetings for user roles: 'admin', 'editor', 'guest', and a fallback message for any other role. Which Angular template correctly implements this using
*ngSwitch?*ngSwitch?<div [ngSwitch]="userRole"> <div *ngSwitchCase="'admin'">Welcome Admin</div> <div *ngSwitchCase="'editor'">Hello Editor</div> <div *ngSwitchCase="'guest'">Hi Guest</div> <div *ngSwitchDefault>Welcome User</div> </div>correctly uses quoted strings for cases and *ngSwitchDefault for fallback.
<div [ngSwitch]="userRole"> <div *ngSwitchCase="'admin'">Welcome Admin</div> <div *ngSwitchCase="'editor'">Hello Editor</div> <div *ngSwitchCase="'guest'">Hi Guest</div> <div *ngSwitchDefault>Welcome User</div> </div>is the correct Angular template.
15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions