Bird
0
0

Which of the following is the correct way to declare a signal holding a number in Angular?

easy📝 Syntax Q3 of 15
Angular - Signals
Which of the following is the correct way to declare a signal holding a number in Angular?
Aconst counter = new Signal(0);
Bconst counter = signal(0);
Cconst counter = createSignal<number>(0);
Dconst counter = Signal.create(0);
Step-by-Step Solution
Solution:
  1. Step 1: Recall Angular's signal creation syntax

    Angular uses the global function signal() to create signals.
  2. Step 2: Evaluate options

    Only const counter = signal(0); uses the correct syntax: signal(0).
  3. Final Answer:

    const counter = signal(0); -> Option B
  4. Quick Check:

    Use signal() function to create signals [OK]
Quick Trick: Use signal() function to create signals [OK]
Common Mistakes:
  • Using 'new Signal()' which is invalid
  • Using createSignal which is from other frameworks
  • Calling Signal.create which does not exist

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes