Consider an Angular standalone component that receives an input signal. What is the behavior when the input signal value changes?
import { Component, Input, signal } from '@angular/core'; @Component({ selector: 'app-counter', standalone: true, template: ` <p>Count: {{ count() }}</p> ` }) export class CounterComponent { @Input() count = signal(0); }
Think about how Angular signals propagate changes automatically.
Input signals in Angular automatically notify the component when their value changes, so the template updates reactively without manual subscriptions or lifecycle hooks.
Given the following Angular component code, what will be displayed after the button is clicked twice?
import { Component, signal } from '@angular/core'; @Component({ selector: 'app-clicker', standalone: true, template: ` <p>Clicks: {{ clicks() }}</p> <button (click)="increment()">Click me</button> ` }) export class ClickerComponent { clicks = signal(0); increment() { this.clicks.update(c => c + 1); } }
Each button click calls the increment method which updates the signal.
The signal 'clicks' starts at 0 and increments by 1 each time the button is clicked. After two clicks, it will be 2.
Choose the correct syntax to define an input signal property in an Angular standalone component.
Remember to use the correct TypeScript type annotation and decorator syntax.
Option C correctly uses the @Input decorator with a typed Signal property initialized with signal(0). Option C misses the type annotation, B and C have invalid syntax.
Examine the code below. The component receives an input signal but does not update the displayed value when the input changes. What is the cause?
import { Component, Input, signal } from '@angular/core'; @Component({ selector: 'app-display', standalone: true, template: ` <p>Value: {{ value() }}</p> ` }) export class DisplayComponent { @Input() value = signal(0); ngOnChanges() { // No code here } }
Check how the input signal is handled and whether it is replaced or updated.
Reassigning the input signal breaks the reactive connection. The input signal should be passed and used directly without reassignment to keep updates working.
Choose the statement that best describes the difference between model signals and input signals in Angular.
Think about ownership and mutation rights of signals in component design.
Model signals are created and controlled inside the component and can be updated there. Input signals come from parent components and should be treated as read-only to avoid breaking unidirectional data flow.