Components & Templates Flashcards
6 cards from real Angular Web Framework practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 6 Components & Templates flashcards as text
What is a component in Angular?
Answer: A TypeScript class with an HTML template and optional CSS that controls a portion of the UI
An Angular component is a TypeScript class decorated with @Component that defines a selector, template (HTML), and styles (CSS), managing a specific portion of the user interface.
What is data binding in Angular?
Answer: The mechanism for synchronizing data between the component class and its template
Data binding establishes communication between the component's TypeScript class and its HTML template, enabling automatic updates when data changes in either direction.
What is the difference between interpolation and property binding?
Answer: Interpolation uses {{}} for text; property binding uses [] for DOM properties
Interpolation ({{ expression }}) inserts evaluated expressions as text content, while property binding ([property]='expression') sets DOM element properties or component input properties directly.
What are structural directives in Angular?
Answer: Directives like *ngIf and *ngFor that change the DOM layout by adding or removing elements
Structural directives (*ngIf, *ngFor, *ngSwitch) modify the DOM structure by conditionally adding, removing, or manipulating HTML elements based on expressions.
What is the @Input() decorator used for?
Answer: To define a property that can receive data from a parent component
@Input() marks a component property as bindable, allowing parent components to pass data down to child components through property binding in the template.
What is the @Output() decorator and EventEmitter used for?
Answer: To emit custom events from a child component to its parent
@Output() combined with EventEmitter allows child components to emit custom events that parent components can listen to and respond to, enabling child-to-parent communication.