Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions adev-es/src/content/reference/errors/NG0100.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Expression Changed After Checked

<docs-video src="https://www.youtube.com/embed/O47uUnJjbJc"/>

Angular throws an `ExpressionChangedAfterItHasBeenCheckedError` when an expression value has been changed after change detection has completed. Angular only throws this error in development mode.

In development mode, Angular performs an additional check after each change detection run, to ensure the bindings haven't changed. This catches errors where the view is left in an inconsistent state. This can occur, for example, if a method or getter returns a different value each time it is called, or if a child component changes values on its parent. If either of these occurs, this is a sign that change detection is not stabilized. Angular throws the error to ensure data is always reflected correctly in the view, which prevents erratic UI behavior or a possible infinite loop.

This error commonly occurs when you've added template expressions or have begun to implement lifecycle hooks like `ngAfterViewInit` or `ngOnChanges`. It is also common when dealing with loading status and asynchronous operations, or when a child component changes its parent bindings.

## Debugging the error

The [source maps](https://developer.mozilla.org/docs/Tools/Debugger/How_to/Use_a_source_map) generated by the CLI are very useful when debugging. Navigate up the call stack until you find a template expression where the value displayed in the error has changed.

Ensure that there are no changes to the bindings in the template after change detection is run. This often means refactoring to use the correct component lifecycle hook for your use case. If the issue exists within `ngAfterViewInit`, the recommended solution is to use a constructor or `ngOnInit` to set initial values, or use `ngAfterContentInit` for other value bindings.

If you are binding to methods in the view, ensure that the invocation does not update any of the other bindings in the template.

Read more about which solution is right for you in ['Everything you need to know about the "ExpressionChangedAfterItHasBeenCheckedError" error'](https://angularindepth.com/posts/1001/everything-you-need-to-know-about-the-expressionchangedafterithasbeencheckederror-error) and why this is useful at ['Angular Debugging "Expression has changed after it was checked": Simple Explanation (and Fix)'](https://blog.angular-university.io/angular-debugging).
16 changes: 8 additions & 8 deletions adev-es/src/content/reference/errors/NG0100.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

<docs-video src="https://www.youtube.com/embed/O47uUnJjbJc"/>

Angular throws an `ExpressionChangedAfterItHasBeenCheckedError` when an expression value has been changed after change detection has completed. Angular only throws this error in development mode.
Angular lanza un `ExpressionChangedAfterItHasBeenCheckedError` cuando el valor de una expresión ha cambiado después de que la detección de cambios ha completado. Angular solo lanza este error en modo de desarrollo.

In development mode, Angular performs an additional check after each change detection run, to ensure the bindings haven't changed. This catches errors where the view is left in an inconsistent state. This can occur, for example, if a method or getter returns a different value each time it is called, or if a child component changes values on its parent. If either of these occurs, this is a sign that change detection is not stabilized. Angular throws the error to ensure data is always reflected correctly in the view, which prevents erratic UI behavior or a possible infinite loop.
En modo de desarrollo, Angular realiza una verificación adicional después de cada ejecución de detección de cambios para asegurarse de que los enlaces no hayan cambiado. Esto detecta errores donde la vista queda en un estado inconsistente. Esto puede ocurrir, por ejemplo, si un método o getter devuelve un valor diferente cada vez que se llama, o si un componente hijo cambia valores en su componente padre. Si cualquiera de estos casos ocurre, es una señal de que la detección de cambios no se ha estabilizado. Angular lanza el error para garantizar que los datos siempre se reflejen correctamente en la vista, lo que previene un comportamiento errático de la UI o un posible bucle infinito.

This error commonly occurs when you've added template expressions or have begun to implement lifecycle hooks like `ngAfterViewInit` or `ngOnChanges`. It is also common when dealing with loading status and asynchronous operations, or when a child component changes its parent bindings.
Este error ocurre comúnmente cuando has agregado expresiones de plantilla o has comenzado a implementar hooks de ciclo de vida como `ngAfterViewInit` o `ngOnChanges`. También es común cuando se trabaja con estados de carga y operaciones asíncronas, o cuando un componente hijo cambia los enlaces de su componente padre.

## Debugging the error
## Depurando el error

The [source maps](https://developer.mozilla.org/docs/Tools/Debugger/How_to/Use_a_source_map) generated by the CLI are very useful when debugging. Navigate up the call stack until you find a template expression where the value displayed in the error has changed.
Los [source maps](https://developer.mozilla.org/docs/Tools/Debugger/How_to/Use_a_source_map) generados por el CLI son muy útiles para depurar. Navega hacia arriba en la pila de llamadas hasta encontrar una expresión de plantilla donde el valor mostrado en el error haya cambiado.

Ensure that there are no changes to the bindings in the template after change detection is run. This often means refactoring to use the correct component lifecycle hook for your use case. If the issue exists within `ngAfterViewInit`, the recommended solution is to use a constructor or `ngOnInit` to set initial values, or use `ngAfterContentInit` for other value bindings.
Asegúrate de que no haya cambios en los enlaces de la plantilla después de que se ejecute la detección de cambios. Esto generalmente implica refactorizar para usar el hook de ciclo de vida correcto para tu caso de uso. Si el problema existe dentro de `ngAfterViewInit`, la solución recomendada es usar un constructor o `ngOnInit` para establecer valores iniciales, o usar `ngAfterContentInit` para otros enlaces de valores.

If you are binding to methods in the view, ensure that the invocation does not update any of the other bindings in the template.
Si estás enlazando a métodos en la vista, asegúrate de que la invocación no actualice ninguno de los otros enlaces en la plantilla.

Read more about which solution is right for you in ['Everything you need to know about the "ExpressionChangedAfterItHasBeenCheckedError" error'](https://angularindepth.com/posts/1001/everything-you-need-to-know-about-the-expressionchangedafterithasbeencheckederror-error) and why this is useful at ['Angular Debugging "Expression has changed after it was checked": Simple Explanation (and Fix)'](https://blog.angular-university.io/angular-debugging).
Lee más sobre qué solución es la correcta para ti en ['Everything you need to know about the "ExpressionChangedAfterItHasBeenCheckedError" error'](https://angularindepth.com/posts/1001/everything-you-need-to-know-about-the-expressionchangedafterithasbeencheckederror-error) y por qué esto es útil en ['Angular Debugging "Expression has changed after it was checked": Simple Explanation (and Fix)'](https://blog.angular-university.io/angular-debugging).
20 changes: 20 additions & 0 deletions adev-es/src/content/reference/errors/NG01101.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Wrong Async Validator Return Type

Async validators must return a promise or an observable, and emit/resolve them whether the validation fails or succeeds. In particular, they must implement the [AsyncValidatorFn API](api/forms/AsyncValidator)

```typescript
export function isTenAsync(control: AbstractControl):
Observable<ValidationErrors | null> {
const v: number = control.value;
if (v !== 10) {
// Emit an object with a validation error.
return of({ 'notTen': true, 'requiredValue': 10 });
}
// Emit null, to indicate no error occurred.
return of(null);
}
```

## Debugging the error

Did you mistakenly use a synchronous validator instead of an async validator?
10 changes: 5 additions & 5 deletions adev-es/src/content/reference/errors/NG01101.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Wrong Async Validator Return Type

Async validators must return a promise or an observable, and emit/resolve them whether the validation fails or succeeds. In particular, they must implement the [AsyncValidatorFn API](api/forms/AsyncValidator)
Los validadores asíncronos deben retornar una promesa o un observable, y emitirlos/resolverlos tanto si la validación falla como si tiene éxito. En particular, deben implementar la [API AsyncValidatorFn](api/forms/AsyncValidator)

```typescript
export function isTenAsync(control: AbstractControl):
Observable<ValidationErrors | null> {
const v: number = control.value;
if (v !== 10) {
// Emit an object with a validation error.
// Emite un objeto con un error de validación.
return of({ 'notTen': true, 'requiredValue': 10 });
}
// Emit null, to indicate no error occurred.
// Emite null, para indicar que no ocurrió ningún error.
return of(null);
}
```

## Debugging the error
## Depurando el error

Did you mistakenly use a synchronous validator instead of an async validator?
¿Usaste por error un validador síncrono en lugar de un validador asíncrono?
26 changes: 26 additions & 0 deletions adev-es/src/content/reference/errors/NG01203.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Missing value accessor

For all custom form controls, you must register a value accessor.

Here's an example of how to provide one:

```typescript
providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => MyInputField),
multi: true,
}
]
```

## Debugging the error

As described above, your control was expected to have a value accessor, but was missing one. However, there are many different reasons this can happen in practice. Here's a listing of some known problems leading to this error.

1. If you **defined** a custom form control, did you remember to provide a value accessor?
1. Did you put `ngModel` on an element with no value, or an **invalid element** (e.g. `<div [(ngModel)]="foo">`)?
1. Are you using a custom form control declared inside an `NgModule`? if so, make sure you are **importing** the `NgModule`.
1. Are you using `ngModel` with a third-party custom form control? Check whether that control provides a value accessor. If not, use **`ngDefaultControl`** on the control's element.
1. Are you **testing** a custom form control? Be sure to configure your testbed to know about the control. You can do so with `Testbed.configureTestingModule`.
1. Are you using **Nx and Module Federation** with webpack? Your `webpack.config.js` may require [extra configuration](https://github.com/angular/angular/issues/43821#issuecomment-1054845431) to ensure the forms package is shared.
20 changes: 10 additions & 10 deletions adev-es/src/content/reference/errors/NG01203.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Missing value accessor

For all custom form controls, you must register a value accessor.
Para todos los controles de formulario personalizados, debes registrar un accessor de valor.

Here's an example of how to provide one:
Aquí hay un ejemplo de cómo proporcionar uno:

```typescript
providers: [
Expand All @@ -14,13 +14,13 @@ providers: [
]
```

## Debugging the error
## Depurando el error

As described above, your control was expected to have a value accessor, but was missing one. However, there are many different reasons this can happen in practice. Here's a listing of some known problems leading to this error.
Como se describió anteriormente, se esperaba que tu control tuviera un accessor de valor, pero le faltaba uno. Sin embargo, hay muchas razones diferentes por las que esto puede suceder en la práctica. Aquí hay una lista de algunos problemas conocidos que llevan a este error.

1. If you **defined** a custom form control, did you remember to provide a value accessor?
1. Did you put `ngModel` on an element with no value, or an **invalid element** (e.g. `<div [(ngModel)]="foo">`)?
1. Are you using a custom form control declared inside an `NgModule`? if so, make sure you are **importing** the `NgModule`.
1. Are you using `ngModel` with a third-party custom form control? Check whether that control provides a value accessor. If not, use **`ngDefaultControl`** on the control's element.
1. Are you **testing** a custom form control? Be sure to configure your testbed to know about the control. You can do so with `Testbed.configureTestingModule`.
1. Are you using **Nx and Module Federation** with webpack? Your `webpack.config.js` may require [extra configuration](https://github.com/angular/angular/issues/43821#issuecomment-1054845431) to ensure the forms package is shared.
1. Si **definiste** un control de formulario personalizado, ¿recuerdas proporcionar un accessor de valor?
1. ¿Pusiste `ngModel` en un elemento sin valor, o en un **elemento inválido** (por ejemplo, `<div [(ngModel)]="foo">`)?
1. ¿Estás usando un control de formulario personalizado declarado dentro de un `NgModule`? Si es así, asegúrate de estar **importando** el `NgModule`.
1. ¿Estás usando `ngModel` con un control de formulario personalizado de terceros? Verifica si ese control proporciona un accessor de valor. Si no lo hace, usa **`ngDefaultControl`** en el elemento del control.
1. ¿Estás **probando** un control de formulario personalizado? Asegúrate de configurar tu testbed para que conozca el control. Puedes hacerlo con `Testbed.configureTestingModule`.
1. ¿Estás usando **Nx y Module Federation** con webpack? Tu `webpack.config.js` puede requerir [configuración adicional](https://github.com/angular/angular/issues/43821#issuecomment-1054845431) para asegurarte de que el paquete de formularios sea compartido.
12 changes: 12 additions & 0 deletions adev-es/src/content/reference/errors/NG0200.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Circular Dependency in DI

<docs-video src="https://www.youtube.com/embed/CpLOm4o_FzM"/>

A cyclic dependency exists when a [dependency of a service](guide/di/hierarchical-dependency-injection) directly or indirectly depends on the service itself. For example, if `UserService` depends on `EmployeeService`, which also depends on `UserService`. Angular will have to instantiate `EmployeeService` to create `UserService`, which depends on `UserService`, itself.

## Debugging the error

Use the call stack to determine where the cyclical dependency exists.
You will be able to see if any child dependencies rely on the original file by [mapping out](guide/di/di-in-action) the component, module, or service's dependencies, and identifying the loop causing the problem.

Break this loop \(or circle\) of dependency to resolve this error. This most commonly means removing or refactoring the dependencies to not be reliant on one another.
10 changes: 5 additions & 5 deletions adev-es/src/content/reference/errors/NG0200.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

<docs-video src="https://www.youtube.com/embed/CpLOm4o_FzM"/>

A cyclic dependency exists when a [dependency of a service](guide/di/hierarchical-dependency-injection) directly or indirectly depends on the service itself. For example, if `UserService` depends on `EmployeeService`, which also depends on `UserService`. Angular will have to instantiate `EmployeeService` to create `UserService`, which depends on `UserService`, itself.
Existe una dependencia cíclica cuando una [dependencia de un servicio](guide/di/hierarchical-dependency-injection) depende directa o indirectamente del servicio mismo. Por ejemplo, si `UserService` depende de `EmployeeService`, que a su vez depende de `UserService`. Angular tendría que instanciar `EmployeeService` para crear `UserService`, el cual depende de `UserService` en sí mismo.

## Debugging the error
## Depurando el error

Use the call stack to determine where the cyclical dependency exists.
You will be able to see if any child dependencies rely on the original file by [mapping out](guide/di/di-in-action) the component, module, or service's dependencies, and identifying the loop causing the problem.
Usa la pila de llamadas para determinar dónde existe la dependencia cíclica.
Podrás ver si alguna dependencia hija depende del archivo original [trazando](guide/di/di-in-action) las dependencias del componente, módulo o servicio e identificando el bucle que causa el problema.

Break this loop \(or circle\) of dependency to resolve this error. This most commonly means removing or refactoring the dependencies to not be reliant on one another.
Rompe este bucle \(o círculo\) de dependencia para resolver este error. Esto generalmente significa eliminar o refactorizar las dependencias para que no dependan unas de otras.
19 changes: 19 additions & 0 deletions adev-es/src/content/reference/errors/NG0201.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# No Provider Found

<docs-video src="https://www.youtube.com/embed/lAlOryf1-WU"/>

You see this error when you try to inject a service but have not declared a corresponding provider. A provider is a mapping that supplies a value that you can inject into the constructor of a class in your application.

Read more on providers in our [Dependency Injection guide](guide/di).

## Debugging the error

Work backwards from the object where the error states that a provider is missing: `No provider for ${this}!`. This is commonly thrown in services, which require non-existing providers.

To fix the error ensure that your service is registered in the list of providers of an `NgModule` or has the `@Injectable` decorator with a `providedIn` property at top.

The most common solution is to add a provider in `@Injectable` using `providedIn`:

```ts
@Injectable({ providedIn: 'app' })
```
12 changes: 6 additions & 6 deletions adev-es/src/content/reference/errors/NG0201.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

<docs-video src="https://www.youtube.com/embed/lAlOryf1-WU"/>

You see this error when you try to inject a service but have not declared a corresponding provider. A provider is a mapping that supplies a value that you can inject into the constructor of a class in your application.
Ves este error cuando intentas inyectar un servicio pero no has declarado el proveedor correspondiente. Un proveedor es un mapeo que suministra un valor que puedes inyectar en el constructor de una clase en tu aplicación.

Read more on providers in our [Dependency Injection guide](guide/di).
Lee más sobre proveedores en nuestra [guía de Inyección de Dependencias](guide/di).

## Debugging the error
## Depurando el error

Work backwards from the object where the error states that a provider is missing: `No provider for ${this}!`. This is commonly thrown in services, which require non-existing providers.
Trabaja hacia atrás desde el objeto donde el error indica que falta un proveedor: `No provider for ${this}!`. Este error comúnmente se lanza en servicios que requieren proveedores inexistentes.

To fix the error ensure that your service is registered in the list of providers of an `NgModule` or has the `@Injectable` decorator with a `providedIn` property at top.
Para corregir el error, asegúrate de que tu servicio esté registrado en la lista de proveedores de un `NgModule` o tenga el decorador `@Injectable` con una propiedad `providedIn` en la parte superior.

The most common solution is to add a provider in `@Injectable` using `providedIn`:
La solución más común es agregar un proveedor en `@Injectable` usando `providedIn`:

```ts
@Injectable({ providedIn: 'app' })
Expand Down
Loading
Loading