0
0
Angularframework~10 mins

Signal-based components in Angular - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a signal with initial value 0.

Angular
const count = signal([1]);
Drag options to blanks, or click blank then click option'
A0
B''
Cundefined
Dnull
Attempts:
3 left
💡 Hint
Common Mistakes
Using null or undefined as initial value causes unexpected behavior.
Leaving the initial value empty causes errors.
2fill in blank
medium

Complete the code to update the signal value by adding 1.

Angular
count.set(count.[1]() + 1);
Drag options to blanks, or click blank then click option'
Aread
Bvalue
Ccurrent
Dget
Attempts:
3 left
💡 Hint
Common Mistakes
Using value property which does not exist.
Using read or current which are invalid.
3fill in blank
hard

Fix the error in the component to inject the signal correctly.

Angular
import { Component, [1] } from '@angular/core';
Drag options to blanks, or click blank then click option'
AinjectSignal
Binject
CuseSignal
DsignalInject
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent functions like injectSignal or signalInject.
Confusing with hooks or other framework methods.
4fill in blank
hard

Fill both blanks to create a signal and update it on button click.

Angular
const clicks = [1](0);

function onClick() {
  clicks.[2](clicks.get() + 1);
}
Drag options to blanks, or click blank then click option'
Asignal
Bset
Cupdate
DcreateSignal
Attempts:
3 left
💡 Hint
Common Mistakes
Using update instead of set to change signal value.
Using createSignal which is not an Angular function.
5fill in blank
hard

Fill all three blanks to create a standalone component with a signal and display its value.

Angular
import { Component, [1] } from '@angular/core';

@Component({
  selector: 'app-counter',
  standalone: true,
  template: `<button (click)="increment()">Clicked [2] times</button>`
})
export class CounterComponent {
  count = [3](0);

  increment() {
    this.count.set(this.count.get() + 1);
  }
}
Drag options to blanks, or click blank then click option'
Asignal
Bcount
Dinject
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing import names or variable names.
Not matching the variable name in template and class.