Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is a signal in Angular?
A signal is a special kind of variable that holds state and notifies the app when its value changes, allowing automatic updates in the UI.
Click to reveal answer
beginner
How do you create a signal in Angular?
Use the <code>signal()</code> function from Angular to create a signal, for example: <code>const count = signal(0);</code>
Click to reveal answer
intermediate
How do signals improve state management compared to traditional methods?
Signals automatically track dependencies and update only the parts of the UI that use the changed state, reducing manual subscriptions and improving performance.
Click to reveal answer
beginner
What is the difference between a signal and a regular variable?
A regular variable does not notify the app when it changes, but a signal triggers updates wherever it is used, keeping the UI in sync automatically.
Click to reveal answer
beginner
How can you update the value of a signal?
Use the set() method or call the signal as a function with a new value, for example: count.set(5); or count(5);
Click to reveal answer
What does a signal in Angular do?
ATracks state changes and updates the UI automatically
BCreates a new component
CDefines routes in the app
DHandles HTTP requests
✗ Incorrect
Signals hold state and notify Angular to update the UI when the state changes.
Which function creates a signal in Angular?
Anew Signal()
BuseState()
Csignal()
DcreateSignal()
✗ Incorrect
Angular uses the signal() function to create signals.
How do you update a signal's value?
AUsing set() or calling the signal as a function
BDirectly assigning a new value like a normal variable
CUsing updateSignal() method
DSignals cannot be updated
✗ Incorrect
Signals provide set() method or can be called as functions to update their value.
Why are signals better than manual subscriptions?
AThey require more code to manage
BThey automatically track dependencies and update UI efficiently
CThey slow down the app
DThey replace CSS styling
✗ Incorrect
Signals reduce boilerplate by auto-tracking and updating only what needs to change.
Which of these is NOT true about signals?
ASignals can be updated with set()
BSignals notify the app when their value changes
CSignals help keep UI in sync with state
DSignals are used to define routes
✗ Incorrect
Signals are for state management, not routing.
Explain what signals are in Angular and how they help manage state.
Think about how signals replace manual subscriptions and keep UI updated.
You got /4 concepts.
Describe how to create and update a signal in Angular with simple code examples.
Focus on the syntax and methods to change signal values.
You got /3 concepts.
Practice
(1/5)
1. What is the main purpose of using signal() in Angular?
easy
A. To style elements dynamically
B. To create a reactive state value that updates the UI automatically
C. To handle HTTP requests
D. To define a new component
Solution
Step 1: Understand the role of signal()
signal() creates a reactive value that Angular tracks for changes.
Step 2: Connect signal() to UI updates
When the signal value changes, Angular automatically updates the UI where it is used.
Final Answer:
To create a reactive state value that updates the UI automatically -> Option B
Quick Check:
signal() creates reactive state [OK]
Hint: Signals hold reactive values that auto-update UI [OK]
Common Mistakes:
Confusing signals with components
Thinking signals handle HTTP
Assuming signals are for styling
2. Which of the following is the correct way to create a signal with initial value 10 in Angular?
easy
A. const count = signal(10);
B. const count = new Signal(10);
C. const count = createSignal(10);
D. const count = signal.set(10);
Solution
Step 1: Recall the syntax for creating signals
Angular uses signal(initialValue) to create a signal with a starting value.
Step 2: Check each option's syntax
Only const count = signal(10); matches the correct syntax. Others use incorrect constructors or methods.
The signal count starts at 0, then set(5) changes its value to 5.
Step 2: Reading the signal value
Calling count() returns the current value, which is 5 after the update.
Final Answer:
5 -> Option A
Quick Check:
count.set(5) updates value, count() reads it [OK]
Hint: Use count() to read updated signal value [OK]
Common Mistakes:
Thinking count() returns initial value
Confusing set() with reading value
Assuming count is not callable
4. Identify the error in this Angular signal code:
const name = signal('Alice');
name.update(name + ' Smith');
medium
A. Incorrect initial value type for signal
B. Missing parentheses when calling signal()
C. Using update() with a string instead of a function
D. Using set() instead of update()
Solution
Step 1: Understand update() usage
update() expects a function that receives the current value and returns the new value.
Step 2: Analyze the code's argument to update()
The code passes name + ' Smith' which is a string, not a function, causing an error.
Final Answer:
Using update() with a string instead of a function -> Option C
Quick Check:
update() needs a function argument [OK]
Hint: Pass a function to update(), not a direct value [OK]
Common Mistakes:
Passing value directly to update()
Confusing set() and update() usage
Ignoring function argument requirement
5. You want to create a signal that holds a list of numbers and add a new number to it reactively. Which code correctly updates the signal to add number 7?
hard
A. numbers.push(7);
B. numbers.set(numbers() + 7);
C. numbers = signal([...numbers(), 7]);
D. numbers.update(list => [...list, 7]);
Solution
Step 1: Understand how to update array signals
Signals hold values immutably; to add an item, create a new array with the old items plus the new one.
Step 2: Check each option's correctness
numbers.update(list => [...list, 7]); uses update() with a function that returns a new array including 7, which is correct. numbers.set(numbers() + 7); tries to add 7 to an array directly, causing a type error. numbers = signal([...numbers(), 7]); tries to reassign the signal variable, which is incorrect. numbers.push(7); calls push() on the signal itself, which is not valid.
Final Answer:
numbers.update(list => [...list, 7]); -> Option D
Quick Check:
Use update() with function returning new array [OK]
Hint: Use update(fn) to immutably add items to array signals [OK]