( token: InjectionToken<T> | Constructor<T>, options?: unknown, )
| 39 | |
| 40 | export function inject<T>(token: InjectionToken<T> | Constructor<T>): T; |
| 41 | export function inject<T>( |
| 42 | token: InjectionToken<T> | Constructor<T>, |
| 43 | options?: unknown, |
| 44 | ): T | NotFound { |
| 45 | const currentInjector = getCurrentInjector(); |
| 46 | if (!currentInjector) { |
| 47 | throw new Error('Current injector is not set.'); |
| 48 | } |
| 49 | if (!(token as InjectionToken<T>).ɵprov) { |
| 50 | throw new Error('Token is not an injectable'); |
| 51 | } |
| 52 | return currentInjector.retrieve(token as InjectionToken<T>, options); |
| 53 | } |
no test coverage detected