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