Skip to content

Instantly share code, notes, and snippets.

@andrewarosario
Last active February 25, 2021 01:11
Show Gist options
  • Save andrewarosario/79b9c64e2431ccaa460e996071fc2e0f to your computer and use it in GitHub Desktop.
Save andrewarosario/79b9c64e2431ccaa460e996071fc2e0f to your computer and use it in GitHub Desktop.
export const ROUTE_ID = new InjectionToken<Observable<string>>(
'Returns an observable in the route id being passed as a parameter',
);
export function routeIdFactory(route: ActivatedRoute): Observable<string> {
return route.paramMap.pipe(map(params => params.get('id')));
}
export const ROUTE_ID_PROVIDERS: Provider[] = [
{
provide: ROUTE_ID,
deps: [ActivatedRoute],
useFactory: routeIdFactory,
},
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment