Angular Architecture & Modules Quiz – 20 Questions with Answers
20 questions · 15 min · Medium
Test your knowledge of Angular directives, including structural directives, attribute directives, built-in directives, ngIf, ngFor, ngClass, ngStyle, and custom directives.
No sign-up needed · Last updated:
Score: 0 00:00
Create a free account to keep your scores and track your progress. It is optional.
20 questions · 15 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
A. A class that adds behavior or changes the appearance of DOM elements
Angular directives are classes that can add behavior to elements or modify their appearance and structure.
A. Structural directive
Structural directives change the DOM layout by adding, removing, or manipulating elements.
A. ngIf
The traditional *ngIf structural directive conditionally creates or removes an element from the DOM.
A. ngFor
The traditional *ngFor structural directive creates a template instance for each item in an iterable collection.
A. The directive is applied through Angular's structural template syntax
The * syntax is shorthand for Angular's structural directive template syntax and is traditionally used with directives such as *ngIf and *ngFor.
A. Attribute directive
Attribute directives modify the behavior or appearance of an existing element, component, or another directive.
A. ngClass
ngClass allows CSS classes to be added or removed dynamically based on component data.
A. ngStyle
ngStyle allows inline CSS styles to be applied dynamically based on component expressions.
A. ngClass
ngClass is an attribute directive because it changes the classes of an existing element rather than changing the DOM structure.
A. @Directive
The @Directive decorator is used to define a directive class and configure its selector and other metadata.
A. selector
The selector property determines which elements or attributes the directive applies to.
A. ngSwitch
The traditional ngSwitch directive works with ngSwitchCase and ngSwitchDefault to conditionally display different template content.
A. Structural directives change the DOM structure, while attribute directives modify appearance or behavior
Structural directives control whether and how elements are created in the DOM, while attribute directives modify existing elements.
A. @if
Modern Angular provides built-in control flow syntax such as @if for conditional rendering, alongside the traditional structural directive approach.
A. @for
Modern Angular provides the @for block for iterating over collections, replacing many common uses of the traditional *ngFor directive.