0
0
Angularframework~20 mins

Signal creation and reading in Angular - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Signal Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What is the output of this Angular signal example?
Consider this Angular standalone component using signals. What will be displayed in the browser?
Angular
import { Component, signal } from '@angular/core';

@Component({
  selector: 'app-counter',
  standalone: true,
  template: `<p>Count: {{ count() }}</p>`
})
export class CounterComponent {
  count = signal(5);
}
ACount: 0
BCount: 5
CCount: undefined
DError: signal is not a function
Attempts:
2 left
💡 Hint
Remember that signals hold a value and you read it by calling the signal as a function.
state_output
intermediate
2:00remaining
What is the value of the signal after this code runs?
Given this Angular code snippet, what is the final value of the signal 'name'?
Angular
import { signal } from '@angular/core';

const name = signal('Alice');
name.set('Bob');
name.update(current => current + ' Smith');
A'Bob Smith'
B'Alice Smith'
C'Alice Bob Smith'
D'Bob'
Attempts:
2 left
💡 Hint
The update function receives the current value and returns the new value.
📝 Syntax
advanced
2:00remaining
Which option correctly creates a signal and reads its value?
Choose the code snippet that correctly creates a signal with initial value 10 and reads its value into a variable 'currentValue'.
A
const count = signal(10);
const currentValue = count();
B
const count = new signal(10);
const currentValue = count();
C
const count = signal(10);
const currentValue = count.value;
D
const count = signal = 10;
const currentValue = count;
Attempts:
2 left
💡 Hint
Signals are functions to read their value, not objects with a 'value' property.
🔧 Debug
advanced
2:00remaining
What error does this Angular signal code produce?
Analyze this code snippet. What error will Angular throw when running this?
Angular
import { signal } from '@angular/core';

const count = signal(0);
console.log(count.value);
ASyntaxError: Unexpected token '.'
BReferenceError: signal is not defined
CTypeError: count.value is undefined
DNo error, logs undefined
Attempts:
2 left
💡 Hint
Signals are functions, not objects with a 'value' property.
🧠 Conceptual
expert
3:00remaining
How does Angular's signal system improve component reactivity?
Which statement best explains how Angular signals improve reactivity compared to traditional state management?
ASignals store state in global variables accessible by all components.
BSignals require explicit event listeners to update components on state change.
CSignals automatically track dependencies and update only affected parts without manual subscriptions.
DSignals force full component re-render on any state change regardless of usage.
Attempts:
2 left
💡 Hint
Think about how signals track what uses their value and update selectively.