Angular · Concept
Lazy loading
Angular's injectAsync helper loads an auto-provided service only when it is needed. It returns a function that resolves to the service instance through a promise.
Last updated
Syntax
function injectAsync<T>(loader: () => Promise<ProviderToken<T>>, options?: InjectAsyncOptions | undefined): () => Promise<T>;In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
InjectAsyncOptionsProviderTokenonIdle@Injectable({providedIn: 'root'})@Service()