Last active
February 25, 2021 01:11
-
-
Save andrewarosario/79b9c64e2431ccaa460e996071fc2e0f to your computer and use it in GitHub Desktop.
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
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