You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Welcome to the Angular signals tutorial! [Signals](/essentials/signals) are Angular's reactive primitive that provide a way to manage state and automatically update your UI when that state changes.
4
+
5
+
In this activity, you'll learn how to:
6
+
7
+
- Create your first signal using the `signal()` function
8
+
- Display its value in a template
9
+
- Update the signal value using `set()` and `update()` methods
10
+
11
+
Let's build an interactive user status system with signals!
12
+
13
+
<hr />
14
+
15
+
<docs-workflow>
16
+
17
+
<docs-steptitle="Import the signal function">
18
+
Import the `signal` function from `@angular/core` at the top of your component file.
The `update()` method takes a function that receives the current value and returns the new value. This is useful when you need to modify the existing value based on its current state.
106
+
107
+
</docs-step>
108
+
109
+
<docs-steptitle="Add the toggle button handler">
110
+
The toggle button is already in the template. Connect it to your `toggleStatus()` method:
Congratulations! You've created your first signal and learned how to update it using both `set()` and `update()` methods. The `signal()` function creates a reactive value that Angular tracks, and when you update it, your UI automatically reflects the changes.
123
+
124
+
Next, you'll learn [how to derive state from signals using computed](/tutorials/signals/2-deriving-state-with-computed-signals)!
You might notice `ChangeDetectionStrategy.OnPush` in the component decorator throughout this tutorial. This is a performance optimization for Angular components that use signals. For now, you can safely ignore it—just know it helps your app run faster when using signals! You can learn more in the [change detection strategies API docs](/api/core/ChangeDetectionStrategy).
Welcome to the Angular signals tutorial! [Signals](/essentials/signals) are Angular's reactive primitive that provide a way to manage state and automatically update your UI when that state changes.
The `update()` method takes a function that receives the current value and returns the new value. This is useful when you need to modify the existing value based on its current state.
@@ -119,12 +119,12 @@ The toggle button is already in the template. Connect it to your `toggleStatus()
119
119
120
120
</docs-workflow>
121
121
122
-
Congratulations! You've created your first signal and learned how to update it using both `set()` and `update()` methods. The `signal()` function creates a reactive value that Angular tracks, and when you update it, your UI automatically reflects the changes.
You might notice `ChangeDetectionStrategy.OnPush` in the component decorator throughout this tutorial. This is a performance optimization for Angular components that use signals. For now, you can safely ignore it—just know it helps your app run faster when using signals! You can learn more in the [change detection strategies API docs](/api/core/ChangeDetectionStrategy).
0 commit comments