Complete the code to create a signal for managing a counter state.
const counter = [1](0);
In Angular signals, signal creates a reactive state holder.
Complete the code to update the counter signal by increasing its value by 1.
counter.[1](value => value + 1);
The update method changes the signal's value based on the current value.
Fix the error in the code to read the current value of the signal.
const currentValue = counter.[1];Access the current value of a signal using its value property.
Fill both blanks to create a computed signal that doubles the counter value.
const doubleCounter = computed(() => counter.[1] * [2]);
Use counter.value to get the current count and multiply by 2 to double it.
Fill all three blanks to create a standalone component with a signal and a button to increment it.
import { Component, [1] } from '@angular/core'; @Component({ selector: 'app-counter', standalone: true, template: ` <button (click)="increment()">Increment</button> <p>Count: {{ '{{' }} counter.[2] {{'}}' }}</p> ` }) export class CounterComponent { counter = [3](0); increment() { this.counter.update(value => value + 1); } }
Import signal to create the state. Use counter.value to display the current count. Initialize counter with signal(0).