-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(injectors): Spanish translation for injectROuteData (#383)
- Loading branch information
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
docs/src/content/docs/es/utilities/Injectors/inject-route-data.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
title: injectRouteData | ||
description: ngxtension/inject-route-data | ||
entryPoint: inject-route-data | ||
contributors: ['krzysztof-kachniarz'] | ||
--- | ||
|
||
`injectRouteData` es una función auxiliar que nos permite inyectar datos como una signal, que provienen de la ruta actual. | ||
|
||
El tener datos de la ruta como signal nos ayuda en las nuevas arquitecturas angular basadas en signals. | ||
|
||
```ts | ||
import { injectRouteData } from 'ngxtension/inject-route-data'; | ||
``` | ||
|
||
## Uso | ||
|
||
`injectRouteData` cuando se llama, devuelve una signal con los datos actuales de la ruta. | ||
|
||
```ts | ||
@Component({ | ||
standalone: true, | ||
template: '<div>{{routeData() | json}}</div>', | ||
}) | ||
class TestComponent { | ||
routeData = injectRouteData(); | ||
} | ||
``` | ||
|
||
Si queremos obtener el valor de una propiedad específica, podemos pasar el nomre de la propiedad en el objeto a `injectRouteData`. | ||
|
||
```ts | ||
@Component({ | ||
template: ` | ||
<div>{{ details().name }}</div> | ||
<div>{{ details().description }}</div> | ||
`, | ||
}) | ||
class TestComponent { | ||
details = injectRouteData('details'); // devuelve una signal con el valor de la propiedad de los datos de la ruta | ||
} | ||
``` | ||
|
||
O, si necesitamos transformar los datos, podemos pasarle una función a `injectRouteData`. | ||
|
||
```ts | ||
@Component() | ||
class TestComponent { | ||
routeDataKeys = injectRouteData((data) => Object.keys(data)); // devuelve una signal con las propiedades de los datos de la ruta | ||
} | ||
``` |