Skip to content

Commit 2bc7bd1

Browse files
committed
translate: translations form signal forms tutorial
Fixes #168
1 parent 66757e4 commit 2bc7bd1

14 files changed

Lines changed: 541 additions & 136 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Learn Angular Signal Forms
2+
3+
This interactive tutorial will teach you how to build reactive forms using Angular's experimental Signal Forms API.
4+
5+
IMPORTANT: Signal Forms is currently [experimental](reference/releases#experimental). The API may change before stabilizing. Check the [official documentation](guide/forms/signal-forms) for the latest updates.
6+
7+
## How to use this tutorial
8+
9+
This tutorial assumes you understand Angular's core concepts and have basic familiarity with signals. If you're new to Angular, read our [essentials guide](/essentials). If you're new to signals, complete the [signals tutorial](/tutorials/signals) first.
10+
11+
Each step represents a concept in Signal Forms. You'll build a complete login form from scratch, learning the fundamentals step by step.
12+
13+
**Your learning path:**
14+
15+
1. Set up the form model with TypeScript and signals
16+
2. Connect the form to your template
17+
3. Add validation rules
18+
4. Display validation errors to users
19+
5. Handle form submission
20+
6. Explore advanced topics and next steps
21+
22+
If you get stuck, click "Reveal answer" at the top.
23+
24+
Alright, let's [get started](/tutorials/signal-forms/1-set-up-form-model)!
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
# Learn Angular Signal Forms
1+
# Aprende sobre Signal Forms en Angular
22

3-
This interactive tutorial will teach you how to build reactive forms using Angular's experimental Signal Forms API.
3+
Este tutorial interactivo te enseñará cómo construir formularios reactivos usando la API experimental Signal Forms de Angular.
44

5-
IMPORTANT: Signal Forms is currently [experimental](reference/releases#experimental). The API may change before stabilizing. Check the [official documentation](guide/forms/signal-forms) for the latest updates.
5+
IMPORTANTE: Signal Forms es actualmente [experimental](reference/releases#experimental). La API puede cambiar antes de estabilizarse. Consulta la [documentación oficial](guide/forms/signal-forms) para las últimas actualizaciones.
66

7-
## How to use this tutorial
7+
## Cómo usar este tutorial
88

9-
This tutorial assumes you understand Angular's core concepts and have basic familiarity with signals. If you're new to Angular, read our [essentials guide](/essentials). If you're new to signals, complete the [signals tutorial](/tutorials/signals) first.
9+
Este tutorial asume que entiendes los conceptos principales de Angular y tienes familiaridad básica con signals. Si eres nuevo en Angular, lee nuestra [guía esencial](/essentials). Si eres nuevo en signals, completa primero el [tutorial de signals](/tutorials/signals).
1010

11-
Each step represents a concept in Signal Forms. You'll build a complete login form from scratch, learning the fundamentals step by step.
11+
Cada paso representa un concepto en Signal Forms. Construirás un formulario de inicio de sesión completo desde cero, aprendiendo los fundamentos paso a paso.
1212

13-
**Your learning path:**
13+
**Tu ruta de aprendizaje:**
1414

15-
1. Set up the form model with TypeScript and signals
16-
2. Connect the form to your template
17-
3. Add validation rules
18-
4. Display validation errors to users
19-
5. Handle form submission
20-
6. Explore advanced topics and next steps
15+
1. Configurar el modelo del formulario con TypeScript y signals
16+
2. Conectar el formulario a tu plantilla
17+
3. Agregar reglas de validación
18+
4. Mostrar errores de validación a los usuarios
19+
5. Manejar el envío del formulario
20+
6. Explorar temas avanzados y próximos pasos
2121

22-
If you get stuck, click "Reveal answer" at the top.
22+
Si te quedas atascado, haz clic en "Reveal answer" (Mostrar respuesta) en la parte superior.
2323

24-
Alright, let's [get started](/tutorials/signal-forms/1-set-up-form-model)!
24+
Muy bien, ¡[comencemos](/tutorials/signal-forms/1-set-up-form-model)!
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Set up the form model
2+
3+
Every Signal Form starts with a form data model - a signal that defines the shape of your data, and stores your form data.
4+
5+
In this lesson, you'll learn how to:
6+
7+
- Define a TypeScript interface for your form data
8+
- Create a signal to hold form values
9+
- Use the `form()` function to create a Signal Form
10+
11+
Let's build the foundation for our login form!
12+
13+
<hr />
14+
15+
<docs-workflow>
16+
17+
<docs-step title="Define the LoginData interface">
18+
Create a TypeScript interface that defines the structure of your login form data. The form will have:
19+
20+
- An `email` field (string)
21+
- A `password` field (string)
22+
- A `rememberMe` field (boolean)
23+
24+
```ts
25+
interface LoginData {
26+
email: string;
27+
password: string;
28+
rememberMe: boolean;
29+
}
30+
```
31+
32+
Add this interface above the `@Component` decorator.
33+
</docs-step>
34+
35+
<docs-step title="Import signal and form">
36+
Import the `signal` function from `@angular/core` and the `form` function from `@angular/forms/signals`:
37+
38+
```ts
39+
import { Component, signal } from '@angular/core';
40+
import { form } from '@angular/forms/signals';
41+
```
42+
43+
</docs-step>
44+
45+
<docs-step title="Create the form model signal">
46+
In your component class, create a `loginModel` signal with initial values. Use the `LoginData` interface as the type parameter:
47+
48+
```ts
49+
loginModel = signal<LoginData>({
50+
email: '',
51+
password: '',
52+
rememberMe: false,
53+
});
54+
```
55+
56+
The initial values start as empty strings for text fields and `false` for the checkbox.
57+
</docs-step>
58+
59+
<docs-step title="Create the form">
60+
Now create the form by passing your model signal to the `form()` function:
61+
62+
```ts
63+
loginForm = form(this.loginModel);
64+
```
65+
66+
The `form()` function creates a form from your model, giving you access to field state and validation.
67+
</docs-step>
68+
69+
</docs-workflow>
70+
71+
Excellent! You've set up your form model. The `loginModel` signal holds your form data, and the `loginForm` provides access to each field with type safety.
72+
73+
Next, you'll learn [how to connect your form to the template](/tutorials/signal-forms/2-connect-form-template)!
Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
# Set up the form model
1+
# Configurar el modelo del formulario
22

3-
Every Signal Form starts with a form data model - a signal that defines the shape of your data, and stores your form data.
3+
Todo Signal Form comienza con un modelo de datos del formulario — un signal que define la forma de tus datos y almacena los datos de tu formulario.
44

5-
In this lesson, you'll learn how to:
5+
En esta lección, aprenderás cómo:
66

7-
- Define a TypeScript interface for your form data
8-
- Create a signal to hold form values
9-
- Use the `form()` function to create a Signal Form
7+
- Definir una interfaz TypeScript para los datos de tu formulario
8+
- Crear un signal para mantener los valores del formulario
9+
- Usar la función `form()` para crear un Signal Form
1010

11-
Let's build the foundation for our login form!
11+
¡Construyamos la base para nuestro formulario de inicio de sesión!
1212

1313
<hr />
1414

1515
<docs-workflow>
1616

17-
<docs-step title="Define the LoginData interface">
18-
Create a TypeScript interface that defines the structure of your login form data. The form will have:
17+
<docs-step title="Define la interfaz LoginData">
18+
Crea una interfaz TypeScript que defina la estructura de los datos de tu formulario de inicio de sesión. El formulario tendrá:
1919

20-
- An `email` field (string)
21-
- A `password` field (string)
22-
- A `rememberMe` field (boolean)
20+
- Un campo `email` (string)
21+
- Un campo `password` (string)
22+
- Un campo `rememberMe` (boolean)
2323

2424
```ts
2525
interface LoginData {
@@ -29,11 +29,11 @@ interface LoginData {
2929
}
3030
```
3131

32-
Add this interface above the `@Component` decorator.
32+
Agrega esta interfaz sobre el decorador `@Component`.
3333
</docs-step>
3434

35-
<docs-step title="Import signal and form">
36-
Import the `signal` function from `@angular/core` and the `form` function from `@angular/forms/signals`:
35+
<docs-step title="Importa signal y form">
36+
Importa la función `signal` desde `@angular/core` y la función `form` desde `@angular/forms/signals`:
3737

3838
```ts
3939
import { Component, signal } from '@angular/core';
@@ -42,8 +42,8 @@ import { form } from '@angular/forms/signals';
4242

4343
</docs-step>
4444

45-
<docs-step title="Create the form model signal">
46-
In your component class, create a `loginModel` signal with initial values. Use the `LoginData` interface as the type parameter:
45+
<docs-step title="Crea el signal del modelo del formulario">
46+
En tu clase de componente, crea un signal `loginModel` con valores iniciales. Usa la interfaz `LoginData` como parámetro de tipo:
4747

4848
```ts
4949
loginModel = signal<LoginData>({
@@ -53,21 +53,21 @@ loginModel = signal<LoginData>({
5353
});
5454
```
5555

56-
The initial values start as empty strings for text fields and `false` for the checkbox.
56+
Los valores iniciales comienzan como strings vacíos para los campos de texto y `false` para el checkbox.
5757
</docs-step>
5858

59-
<docs-step title="Create the form">
60-
Now create the form by passing your model signal to the `form()` function:
59+
<docs-step title="Crea el formulario">
60+
Ahora crea el formulario pasando tu signal modelo a la función `form()`:
6161

6262
```ts
6363
loginForm = form(this.loginModel);
6464
```
6565

66-
The `form()` function creates a form from your model, giving you access to field state and validation.
66+
La función `form()` crea un formulario a partir de tu modelo, dándote acceso al estado del campo y la validación.
6767
</docs-step>
6868

6969
</docs-workflow>
7070

71-
Excellent! You've set up your form model. The `loginModel` signal holds your form data, and the `loginForm` provides access to each field with type safety.
71+
¡Excelente! Has configurado tu modelo de formulario. El signal `loginModel` mantiene los datos de tu formulario, y `loginForm` proporciona acceso a cada campo con seguridad de tipos.
7272

73-
Next, you'll learn [how to connect your form to the template](/tutorials/signal-forms/2-connect-form-template)!
73+
A continuación, aprenderás [cómo conectar tu formulario a la plantilla](/tutorials/signal-forms/2-connect-form-template)!
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Connect your form to the template
2+
3+
Now, you need to connect your form to the template using the `[field]` directive. This creates two-way data binding between your form model and the input elements.
4+
5+
In this lesson, you'll learn how to:
6+
7+
- Import the `Field` directive
8+
- Use the `[field]` directive to bind form fields to inputs
9+
- Connect text inputs and checkboxes to your form
10+
- Display form field values in the template
11+
12+
Let's wire up the template!
13+
14+
<hr />
15+
16+
<docs-workflow>
17+
18+
<docs-step title="Import the Field directive">
19+
Import the `Field` directive from `@angular/forms/signals` and add it to your component's imports array:
20+
21+
```ts
22+
import { form, Field } from '@angular/forms/signals';
23+
24+
@Component({
25+
selector: 'app-root',
26+
templateUrl: './app.html',
27+
styleUrl: './app.css',
28+
imports: [Field],
29+
changeDetection: ChangeDetectionStrategy.OnPush,
30+
})
31+
```
32+
33+
</docs-step>
34+
35+
<docs-step title="Bind the email field">
36+
In your template, add the `[field]` directive to the email input:
37+
38+
```html
39+
<input type="email" [field]="loginForm.email" />
40+
```
41+
42+
The `loginForm.email` expression accesses the email field from your form.
43+
</docs-step>
44+
45+
<docs-step title="Bind the password field">
46+
Add the `[field]` directive to the password input:
47+
48+
```html
49+
<input type="password" [field]="loginForm.password" />
50+
```
51+
52+
</docs-step>
53+
54+
<docs-step title="Bind the checkbox field">
55+
Add the `[field]` directive to the checkbox input:
56+
57+
```html
58+
<input type="checkbox" [field]="loginForm.rememberMe" />
59+
```
60+
61+
</docs-step>
62+
63+
<docs-step title="Display the form values">
64+
Below the form, there's a debug section to show current form values. Display each field value using `.value()`:
65+
66+
```html
67+
<p>Email: {{ loginForm.email().value() }}</p>
68+
<p>Password: {{ loginForm.password().value() ? '••••••••' : '(empty)' }}</p>
69+
<p>Remember me: {{ loginForm.rememberMe().value() ? 'Yes' : 'No' }}</p>
70+
```
71+
72+
Form field values are signals, so the displayed values update automatically as you type.
73+
</docs-step>
74+
75+
</docs-workflow>
76+
77+
Great work! You've connected your form to the template and displayed the form values. The `[field]` directive handles two-way data binding automatically - as you type, the `loginModel` signal updates, and the displayed values update immediately.
78+
79+
Next, you'll learn [how to add validation to your form](/tutorials/signal-forms/3-add-validation)!

0 commit comments

Comments
 (0)