Skip to content


Created by Krzysztof Kachniarz

injectRouteFragment is a helper function that allows you to inject url fragment from the current route as a signal.

import { injectRouteFragment } from 'ngxtension/inject-route-fragment';


injectRouteFragment when is called, returns a signal with the current route fragment.

class TestComponent {
fragment = injectRouteFragment();

You can pass transform function or custom injector.

class TestComponent implements OnInit {
injector = inject(Injector);
ngOnInit() {
const isFragmentAvailable: Signal<boolean> = injectRouteFragment({
transform: (fragment) => !!fragment,
injector: this.injector,