diff --git a/docs/src/content/contributors/sergi-dote.json b/docs/src/content/contributors/sergi-dote.json new file mode 100644 index 000000000..8ed13eefa --- /dev/null +++ b/docs/src/content/contributors/sergi-dote.json @@ -0,0 +1,5 @@ +{ + "name": "Sergi Dote Teixidor", + "linkedin": "https://www.linkedin.com/in/sergidote/", + "github": "https://github.com/sergidt" +} diff --git a/docs/src/content/docs/es/utilities/Injectors/inject-route-fragment.md b/docs/src/content/docs/es/utilities/Injectors/inject-route-fragment.md new file mode 100644 index 000000000..54fe83fe7 --- /dev/null +++ b/docs/src/content/docs/es/utilities/Injectors/inject-route-fragment.md @@ -0,0 +1,39 @@ +--- +title: injectRouteFragment +description: ngxtension/inject-route-fragment +entryPoint: inject-route-fragment +contributors: ['sergi-dote'] +--- + +`injectRouteFragment` es una función auxiliar que nos permite inyectar el fragmento url de la ruta actual, como signal. + +```ts +import { injectRouteFragment } from 'ngxtension/inject-route-fragment'; +``` + +## Uso + +`injectRouteFragment` cuando se invoca, devuelve una signal con el fragmento url actual. + +```ts +@Component(...) +class TestComponent { + fragment = injectRouteFragment(); +} +``` + +Podemos pasar una función de transformación o un inyector personalizado. + +```ts +@Component() +class TestComponent implements OnInit { + injector = inject(Injector); + + ngOnInit() { + const isFragmentAvailable: Signal = injectRouteFragment({ + transform: (fragment) => !!fragment, + injector: this.injector, + }); + } +} +```